API Management

Tutorial: Deploying Apigee Edge Microgateway

In a previous post, we discussed some of the features of Apigee Edge Microgateway and the power of hybrid API management.

Here, we’ll walk you through tutorials to deploy Apigee Edge Microgateway as a Docker container, in PaaS platforms like Cloud Foundry, and in cloud-native PaaS platforms like Google App Engine (GAE) and Azure App Services.

Recommended prerequisites

Before you adopt any of these deployment options, there are some steps to complete first:

  1. Configure Microgateway on a VM or host outside of the intended deployment pattern. This will produce a configuration YAML file that will be used in all of the following deployment options. The configuration file is of the format: {orgname}-{env}-config.yaml
  2. Enable plugins as necessary in the YAML file. Configure and set other parameters as necessary (log levels and connection settings, for example).
  3. Develop custom plugins as npm modules. Installation of npm modules can be done via a public npm repo (npm.org) or a private npm repo.
  4. Fork Apigee Edge Microgateway in GitHub for Azure App Services. It’s available on GitHub here. Some cloud vendors (such as Google) even provide local repositories (in which case you can load a clone of the microgateway project).
  5. Edit the config YAML to expose just a set of API proxies. For more information, check out this documentation.

Build a Docker image for Microgateway

In this section we’ll show you how to build a Docker image for Microgateway.

Step 1: Clone the project

  git clone https://github.com/srinandan/apigee-edgemicro-docker

Step 2: Switch the directory

  cd apigee-edgemicro-docker

Step 3: Copy the {org}-{env}-config.yaml

file to the current folder and edit the Dockerfile with the correct file name (see the prerequisites).

Step 4: Build the Docker image

  docker build --build-arg ORG="your-orgname" --build-arg ENV="your-env"
--build-arg KEY="bx..xxx2" --build-arg SECRET="exx..x0" -t microgateway .

Step 5: Start Microgateway

  docker run -d -p 8000:8000 -e EDGEMICRO_ORG="your-orgname" -e
EDGEMICRO_ENV="your-env" -e EDGEMICRO_KEY="bxx..x2" -e
EDGEMICRO_SECRET="ex..x0" -P -it microgateway

The default path for microgateway logs are in /var/tmp. You might want to consider mounting a volume to this folder so the logs are accessible from outside the Docker image.

Microgateway on Google App Engine

Here we’ll walk you through deploying Microgateway as an app on Google App Engine (GAE).

Step 1: Fork or clone the Apigee Edge Microgateway GitHub repo (this is optional).

Step 2: Clone the forked (or main) repo in the gcloud shell.

  git clone https://github.com/apigee-internal/microgateway.git
cd microgateway

Step 3: Copy the {org}-{env}-config.yaml

file to the microgateway/config


Step 4: Review the app.yaml


  # [START runtime]
service: microgateway
runtime: nodejs
env: flex
 min_num_instances: 1
 max_num_instances: 2
cpu: 1
memory_gb: 2
 disk_size_gb: 10
 EDGEMICRO_KEY: 'bx..x2'
 EDGEMICRO_CONFIG_DIR: '/app/config'
 EDGEMICRO_ENV: 'env-name'
 EDGEMICRO_ORG: 'org-name'
# [END runtime]

Review the following fields:

  • The min and max instances (for auto-scaling)
  • Resources (cpu, memory)
  • Microgateway environment variables (key, secret, org and env)
Step 5: Deploy the app to GAE

  gcloud app deploy --project your-project-name

Microgateway on Azure App Services

Here we'll walk you through how to deploy Microgateway as an app on Azure’s App Services platform.

In the Azure portal, perform the following steps:

Step 1: Click on “App Services.”

Step 2: Click on “+ Add.”

Step 3: Search for “node.js”and  select “API App.”


and click “Create.”

Step 4: Enter application details.


Step 5: Click on "Application Settings."

Step 6: Add the environment variables required for Microgateway.


Step 7: Save the settings (key and secret are obtained when Microgateway is configured to the org and env).

Step 8: Fork the Apigee Microgateway repo. Set up deployment option (for example, GitHub) and point it to the Microgateway repo.

Step 9: Enter authentication details to the repo.

Step 10: Ensure the deployment is successful.

Microgateway on Cloud Foundry

In this section, we'll show you how to deploy Microgateway as an app on Cloud Foundry (get all the details in Pivotal’s documentation and GitHub).

Step 1: Fork the Apigee Edge Microgateway GitHub repo (this is optional).

Step 2: Clone the forked (or main) repo

  git clone https://github.com/apigee-internal/microgateway.git
cd microgateway

Step 3: Copy the {org}-{env}-config.yaml

file to the microgateway/config


Add the “cloud-foundry-route-service” plugin to the config file if it doen’t exist in the plugin sequence.

 port: 8000
  max_connections: 1000
     - oauth
     - cloud-foundry-route-service

Step 4: Review the manifest.yml


- name: edgemicro
 memory: 512M
 instances: 1
 host: edgemicro
 path: .
 buildpack: nodejs_buildpack
   EDGEMICRO_KEY: 'bx..x2'
   EDGEMICRO_CONFIG_DIR: '/app/config'
   EDGEMICRO_ENV: 'env-name'
   EDGEMICRO_ORG: 'org-name'

Review the following fields:

  • Instances (for auto-scaling)
  • Memory (min: 512M)
  • Microgateway environment variables (key, secret, org, and env)
 Step 5: Deploy the app to Cloud Foundry

  cf push

Step 6: Review the logs


If your Cloud Foundry instance doesn’t internet access (to download npm modules), you must follow the instructions for using the Node.js buildpack in a disconnected environment here.

Apigee Microgateway is a great choice for microservice developers and teams when they want to add API management features as close to their microservices as possible (to reduce latency), and do so natively (with no additional skills required) to the microservices platform. To learn more, read the Apigee eBook, "Maximizing Microservices."

Questions, comments, or observations? Join the conversation on the Apigee Community.