This guide walks you through deploying and running Kong on Microsoft Azure Container Instances.

We will be using either Azure Database for PostgreSQL or Cosmos Db to store the gateway configuration.

Running Kong on Azure Container Instances

Azure Container Instances is a great way to run lightweight containers in a serverless fashion.

Running Kong on Azure Container Instances is super easy:

  1. Provision a data store

    Provision the data store that you want to use:

    1. Running Cassandra on Azure with Azure Cosmos Db
    2. Running PostgreSQL on Azure with Azure Database for PostgreSQL
  2. Open the Cloud Shell or Azure CLI

  3. Run the migrations

     $ az container create --name kong-migrations \
                           --resource-group kong-sandbox \
                           --image kong:latest \
                           --restart-policy Never \
                           --environment-variables KONG_PG_HOST="<instance-name>.postgres.database.azure.com" \
                                                   KONG_PG_USER="<username>" \
                                                   KONG_PG_PASSWORD="<password>" \
                           --command-line "kong migrations up"
    

    In this example, we are using a PostgreSQL database running on Azure Database for PostgreSQL.

  4. Start Kong

     $ az container create --name kong-gateway /
                           --dns-name-label kong-gateway /
                           --resource-group kong-sandbox /
                           --image kong:latest /
                           --port 8000 8443 8001 8444 /
                           --environment-variables KONG_PG_HOST="<instance-name>.postgres.database.azure.com" /
                                                   KONG_PG_USER="<username>" /
                                                   KONG_PG_PASSWORD="<password>" /
                                                   KONG_PROXY_ACCESS_LOG="/dev/stdout" /
                                                   KONG_ADMIN_ACCESS_LOG="/dev/stdout" /
                                                   KONG_PROXY_ERROR_LOG="/dev/stderr" /
                                                   KONG_ADMIN_ERROR_LOG="/dev/stderr" /
                                                   KONG_ADMIN_LISTEN="0.0.0.0:8001, 0.0.0.0:8444 ssl"
    

    The 8000, 8001, 8443, and 8444 will be forwarded to the container.

    Note: This will expose both the proxy and the Admin API on the default ports. This can have security implications.
  5. Use Kong

    That’s it - You can now use Kong by browsing to <dns-label>.westeurope.azurecontainer.io.

    Quickly learn how to use Kong with the 5-minute Quickstart.

Running PostgreSQL on Azure with Azure Database for PostgreSQL

Azure Database for PostgreSQL is a great way to use a managed PostgreSQL in the Azure Cloud.

Here are the simple steps to provision one:

  1. Go to the Azure Portal
  2. Create a new “Azure Database for PostgreSQL” instance
  3. Go to “Connection Security” and enable access to Azure services
  4. Create a new database called “kong” by using your favorite tool
Note: Before connecting to your new database, make sure your IP address is whitelisted in "Connection Security"

Running Cassandra on Azure with Azure Cosmos Db

Currently, Azure Cosmos Db is not supported as a Cassandra data store.

Note: See #188 for more information.