Azure Key Vault (Certificates)

Kong Gateway can retrieve Azure Key Vault for Certificates for Kong Gateway TLS termination.

You can set up an Azure Key Vault for Certificates vault in one of the following ways:

The Vault entity can only be used once the database is initialized. Secrets for values that are used before the database is initialized can’t make use of the Vaults entity.

Azure Key Vault authentication

Kong Gateway uses a key to automatically authenticate with the Azure Key Vaults API and grant you access. If you’re using a client secret for authentication, set the following environment variable on your data plane to connect with an Azure Key Vault:

export AZURE_CLIENT_SECRET='YOUR_CLIENT_SECRET'

By default, the vault looks for AZURE_CLIENT_SECRET, but you can customize this with the credentials_prefix field.

If you’re using an Instance Managed Identity Token, you don’t need to set the client secret env variable.

Dedicated Cloud Gateway limitations:

  • Azure Key Vault is not supported as a Vault backend on Dedicated Cloud Gateways: Since the client secret has no Vault entity equivalent, it can only be set through this environment variable (or the credentials_prefix variant). Dedicated Cloud Gateways only accept KONG_ and OTEL_ prefixed environment variables, so AZURE_CLIENT_SECRET can’t be set.
  • Azure managed identity is not supported on Dedicated Cloud Gateways.

You also need to set KONG_LUA_SSL_VERIFY_DEPTH to at least 3 on your data plane to allow Kong to verify the Azure Key Vault TLS certificate chain:

export KONG_LUA_SSL_VERIFY_DEPTH=3

At minimum, you’ll also need to set the following values on your data plane:

export KONG_VAULT_AZURE_CERTS_VAULT_URI='https://your-vault.vault.azure.com'
export KONG_VAULT_AZURE_CERTS_TENANT_ID='YOUR_TENANT_ID'
export KONG_VAULT_AZURE_CERTS_CLIENT_ID='YOUR_CLIENT_ID'

Create an Azure Key Vault (Certificates) vault

The following example creates an azure-certs Vault entity. The Vault name must be azure-certs. The vault.prefix value can be your own custom prefix:

Vault configuration options

The following table lists all of the available configuration parameters for an Azure Key Vault (Certificates) vault:

Field name

Parameter format

Description

Vault URI
v3.15+
  • Vault entity: vaults.config.vault_uri
  • kong.conf parameter: vault_azure_certs_vault_uri
  • Environment variable: KONG_VAULT_AZURE_CERTS_VAULT_URI
The URI the vault is reachable from.
Credentials prefix
v3.15+
  • Vault entity: vaults.config.credentials_prefix
The prefix for environment variables used for authentication. The vault reads {prefix}_CLIENT_SECRET from the environment. Defaults to AZURE. This can only be set using the Vault entity.
Client ID
v3.15+
  • Vault entity: vaults.config.client_id
  • kong.conf parameter: vault_azure_certs_client_id
  • Environment variable: KONG_VAULT_AZURE_CERTS_CLIENT_ID
The client ID from your registered Application. Visit your Azure Dashboard and select App Registrations to check your client ID.
Tenant ID
v3.15+
  • Vault entity: vaults.config.tenant_id
  • kong.conf parameter: vault_azure_certs_tenant_id
  • Environment variable: KONG_VAULT_AZURE_CERTS_TENANT_ID
The DirectoryId and TenantId are the same: both refer to the GUID representing your Azure Entra tenant. Depending on context, either term may be used by Microsoft documentation and products. In other words, the “Tenant ID” IS the “Directory ID”.
TTL
v3.15+
  • Vault entity: vaults.config.ttl
  • kong.conf parameter: vault_azure_certs_ttl
  • Environment variable: KONG_VAULT_AZURE_CERTS_TTL
Time-to-live (in seconds) of a certificate from the Azure Key Vault when cached by this node.

Defaults to 3600 (1 hour).

Negative TTL
v3.15+
  • Vault entity: vaults.config.neg_ttl
  • kong.conf parameter: vault_azure_certs_neg_ttl
  • Environment variable: KONG_VAULT_AZURE_CERTS_NEG_TTL
Time-to-live (in seconds) of an Azure Key Vault miss (no certificate).
Resurrect TTL
v3.15+
  • Vault entity: vaults.config.resurrect_ttl
  • kong.conf parameter: vault_azure_certs_resurrect_ttl
  • Environment variable: KONG_VAULT_AZURE_CERTS_RESURRECT_TTL
Time (in seconds) for which stale certificates from the Azure Key Vault should be resurrected when they can’t be refreshed (for example, if the vault is unreachable). When this TTL expires, a new attempt to refresh the stale certificates will be made.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!