Apigee Microgateway Quick Start Guide

Apigee Edge Microgateway installation guide is quite long and for someone who would like to try it out and learn the fundamentals on a local machine may have to spend some time. In this article I will explain the main steps required for quickly installing Edge Microgateway and trying it out.

Prerequisites

  1. An Apigee Edge Cloud Account
  2. Node.js version 6.x LTS or 8.x LTS

Install Microgateway

As you may have already noticed, Apigee Edge Microgateway has been implemented using Node.js. Hence, it can be installed via the npm repository as follows:

npm install edgemicro -g
edgemicro init

Configure and Verify Microgateway

Define Edge Cloud organization name, environment name and username using following environment variables:

export org=[your-edge-cloud-organization]
export env=[your-edge-cloud-environment]
export username=[your-edge-cloud-username]

Execute below command to configure Microgateway:

edgemicro configure -o ${org} -e ${env} -u ${username}

Once configured, it will return a key and a secret. Export that using following environment variables:

export key=# key value returned from configure command
export secret=# secret value returned from configure command

Now, verify the deployment using below command:

edgemicro verify -o ${org} -e ${env} -k ${key} -s ${secret}

Start Microgateway

Once the installation is verified, execute the below command to start Microgateway:

edgemicro start -o ${org} -e ${env} -k ${key} -s ${secret}

Start Microgateway with Forever Monitoring

Microgateway could also be started with Node.js Forever module for automatically restarting if the Microgateway process goes down or has an error:

export EDGEMICRO_ORG=${org}
export EDGEMICRO_ENV=${env}
export EDGEMICRO_KEY=${key}
export EDGEMICRO_SECRET=${secret}
npm install forever -g
edgemicro forever -f /usr/local/lib/node_modules/edgemicro/forever.json -a start &> edgemicro.log

Create a Developer Application

A Developer Application is needed for accessing API proxies deployed on Microgateway which are secured using OAuth v2. Follow below steps for this purpose:

  1. Log into New Edge Cloud UI
  2. Create a new API proxy with the name prefix "edgemicro_" without adding any policies.
  3. Create a new API product by adding edgemicro-auth and above API proxy.
  4. Create a new Developer Application by adding above created API product.
  5. Now, obtain client id and client secret from the above developer application and export to two environment variables:
export client_id=[client id value]
export client_secret=[client secret value]

Obtain an Access Token

Once Microgateway is started successfully, an Access Token can be obtained using below curl command:

curl -i -X POST "http://${org}-${env}.apigee.net/edgemicro-auth/token" \
-H "Content-Type: application/json" \
-d '{
"client_id": "${client_id}",
"client_secret": "${client_secret}",
"grant_type": "client_credentials"
}'

Send an API Request

Now, an API request can be sent to one of the API proxies deployed in Microgateway:

curl -i -H “Authorization: Bearer ${access_token}” 0:8000/{api-resource-path}


References

Comments
sushobhanmondal
New Member

I'm being super pedantic here 🙂 but I believe the Microgateway-aware proxy name should start with edgemicro_ (not dash).

imesh
Staff

Many thanks @sushobhanmondal for pointing that! Yes, API proxy name prefix should be "edgemicro_". I have updated it. Thanks again!

Version history
Last update:
‎05-27-2019 10:20 PM
Updated by: