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.
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
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}
Once the installation is verified, execute the below command to start Microgateway:
edgemicro start -o ${org} -e ${env} -k ${key} -s ${secret}
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
A Developer Application is needed for accessing API proxies deployed on Microgateway which are secured using OAuth v2. Follow below steps for this purpose:
export client_id=[client id value] export client_secret=[client secret value]
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" }'
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}
I'm being super pedantic here 🙂 but I believe the Microgateway-aware proxy name should start with edgemicro_ (not dash).
Many thanks @sushobhanmondal for pointing that! Yes, API proxy name prefix should be "edgemicro_". I have updated it. Thanks again!