Azure API Management API Management

This page shows how to write Terraform and Azure Resource Manager for API Management API Management and write them securely.

azurerm_api_management (Terraform)

The API Management in API Management can be configured in Terraform with the resource name azurerm_api_management. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

api_management_test.tf#L11
resource "azurerm_api_management" "developer1" {
  name                = "example-apim"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  publisher_name      = "My Company"
  publisher_email     = "company@terraform.io"
apim.tf#L1
resource "azurerm_api_management" "main" {
  name                = var.apim.name
  location            = azurerm_resource_group.main.location
  resource_group_name = azurerm_resource_group.main.name
  sku_name            = var.apim.sku
  publisher_name      = var.apim.publisher.name
api_management.tf#L2
resource "azurerm_api_management" "apim" {
  location            = azurerm_resource_group.rg.location
  name                = "log-cabin"
  publisher_email     = "finn.welsford-ackroyd@pm.me"
  publisher_name      = "Log Cabin"
  resource_group_name = azurerm_resource_group.rg.name
main.tf#L9
resource "azurerm_api_management" "i" {
  name = var.name
  location = var.location
  resource_group_name = var.resource_group_name
  publisher_name = "Russell Boley"
  publisher_email = "raboley@gmail.com"
main.tf#L11
resource "azurerm_api_management" "puneet-dev-apim" {
  name                = "puneet-dev-apim"
  location            = var.passed_location
  resource_group_name = var.passed_resource_group_name
  publisher_name      = var.publisher_name
  publisher_email     = var.publisher_email
azure_apim.tf#L11
resource "azurerm_api_management" "global-apim" {
  name                = "kp-global-apim"
  location            = azurerm_resource_group.global-apim.location
  resource_group_name = azurerm_resource_group.global-apim.name
  publisher_name      = "Kallum Parr"
  publisher_email     = "kallum_parr@hotmail.com"
main.tf#L22
resource "azurerm_api_management" "VodafDev" {
  name                = "VodafDev-apim"
  location            = azurerm_resource_group.VodafDev.location
  resource_group_name = azurerm_resource_group.VodafDev.name
  publisher_name      = "Vodafone"
  publisher_email     = "vodafone@terraform.io"
api_management_test.tf#L11
resource "azurerm_api_management" "developer1" {
  name                = "example-apim"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  publisher_name      = "My Company"
  publisher_email     = "company@terraform.io"
apim.tf#L1
resource "azurerm_api_management" "apim" {
  name                = local.apim_name
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  publisher_name      = local.apim_publisher_name
  publisher_email     = local.apim_publisher_email
main.tf#L11
resource "azurerm_api_management" "example" {
  name                = "partnergateway"

}

# terraform import azurerm_api_management.example /subscriptions/000-0000-00000-00000/resourceGroups/ACS_EA_DEV_TEST/providers/Microsoft.ApiManagement/service/partnergateway

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an API Management Service.

Microsoft.ApiManagement/service (Azure Resource Manager)

The service in Microsoft.ApiManagement can be configured in Azure Resource Manager with the resource name Microsoft.ApiManagement/service. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

template.json
{
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workbookDisplayName": {
      "type": "string",
template.json
{
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workbookDisplayName": {
      "type": "string",
AzureInventory.json
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
        "workbookName": {
template.json
{
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workbookDisplayName": {
      "type": "string",
template.json
{
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workbookDisplayName": {
      "type": "string",
template.json
{
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workbookDisplayName": {
      "type": "string",

Parameters

  • apiVersion required - string
  • identity optional
      • type required - string

        The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service.

      • userAssignedIdentities optional - undefined

        The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.

  • location required - string

    Resource location.

  • name required - string

    The name of the API Management service.

  • properties required
      • additionalLocations optional array
          • disableGateway optional - boolean

            Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in this additional location.

          • location required - string

            The location name of the additional region among Azure Data center regions.

          • publicIpAddressId optional - string

            Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the location. Supported only for Premium SKU being deployed in Virtual Network.

          • sku required
              • capacity required - integer

                Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be specified as 0.

              • name required - string

                Name of the Sku.

          • virtualNetworkConfiguration optional
              • subnetResourceId optional - string

                The full resource ID of a subnet in a virtual network to deploy the API Management service in.

          • zones optional - array

            A list of availability zones denoting where the resource needs to come from.

      • apiVersionConstraint optional
          • minApiVersion optional - string

            Limit control plane API calls to API Management service with version equal to or newer than this value.

      • certificates optional array
          • certificate optional
              • expiry required - string

                Expiration date of the certificate. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard.

              • subject required - string

                Subject of the certificate.

              • thumbprint required - string

                Thumbprint of the certificate.

          • certificatePassword optional - string

            Certificate Password.

          • encodedCertificate optional - string

            Base64 Encoded certificate.

          • storeName required - string

            The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations.

      • customProperties optional - string

        Custom properties of the API Management service.</br>Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168 will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).</br>Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11 can be used to disable just TLS 1.1.</br>Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10 can be used to disable TLS 1.0 on an API Management service.</br>Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11 can be used to disable just TLS 1.1 for communications with backends.</br>Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10 can be used to disable TLS 1.0 for communications with backends.</br>Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2 can be used to enable HTTP2 protocol on an API Management service.</br>Not specifying any of these properties on PATCH operation will reset omitted properties' values to their defaults. For all the settings except Http2 the default value is True if the service was created on or before April 1st 2018 and False otherwise. Http2 setting's default value is False.</br></br>You can disable any of next ciphers by using settings Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256:false. The default value is true for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384

      • disableGateway optional - boolean

        Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region.

      • enableClientCertificate optional - boolean

        Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway.

      • hostnameConfigurations optional array
          • certificate optional
              • expiry required - string

                Expiration date of the certificate. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard.

              • subject required - string

                Subject of the certificate.

              • thumbprint required - string

                Thumbprint of the certificate.

          • certificatePassword optional - string

            Certificate Password.

          • certificateSource optional - string

            Certificate Source.

          • certificateStatus optional - string

            Certificate Status.

          • defaultSslBinding optional - boolean

            Specify true to setup the certificate associated with this Hostname as the Default SSL Certificate. If a client does not send the SNI header, then this will be the certificate that will be challenged. The property is useful if a service has multiple custom hostname enabled and it needs to decide on the default ssl certificate. The setting only applied to Proxy Hostname Type.

          • encodedCertificate optional - string

            Base64 Encoded certificate.

          • hostName required - string

            Hostname to configure on the Api Management service.

          • identityClientId optional - string

            System or User Assigned Managed identity clientId as generated by Azure AD, which has GET access to the keyVault containing the SSL certificate.

          • keyVaultId optional - string

            Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url containing version is provided, auto-update of ssl certificate will not work. This requires Api Management service to be configured with aka.ms/apimmsi. The secret should be of type application/x-pkcs12

          • negotiateClientCertificate optional - boolean

            Specify true to always negotiate client certificate on the hostname. Default Value is false.

          • type required - string

            Hostname type.

      • notificationSenderEmail optional - string

        Email address from which the notification will be sent.

      • privateEndpointConnections optional array
          • id optional - string

            Private Endpoint connection resource id

          • name optional - string

            Private Endpoint Connection Name

          • properties optional
              • privateEndpoint optional
                • privateLinkServiceConnectionState required
                    • actionsRequired optional - string

                      A message indicating if changes on the service provider require any updates on the consumer.

                    • description optional - string

                      The reason for approval/rejection of the connection.

                    • status optional - string

                      Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.

            • type optional - string

              Private Endpoint Connection Resource Type

        • publicIpAddressId optional - string

          Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network.

        • publicNetworkAccess optional - string

          Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'.

        • publisherEmail required - string

          Publisher email.

        • publisherName required - string

          Publisher name.

        • restore optional - boolean

          Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored.

        • virtualNetworkConfiguration optional
            • subnetResourceId optional - string

              The full resource ID of a subnet in a virtual network to deploy the API Management service in.

        • virtualNetworkType optional - string

          The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only.

    • sku required
        • capacity required - integer

          Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be specified as 0.

        • name required - string

          Name of the Sku.

    • tags optional - string

      Resource tags.

    • type required - string
    • zones optional - array

      A list of availability zones denoting where the resource needs to come from.

    Frequently asked questions

    What is Azure API Management API Management?

    Azure API Management API Management is a resource for API Management of Microsoft Azure. Settings can be wrote in Terraform.

    Where can I find the example code for the Azure API Management API Management?

    For Terraform, the gilyas/infracost, IvanFarkas/test_api and finn-wa-log-cabin/lc-devops-terraform source code examples are useful. See the Terraform Example section for further details.

    For Azure Resource Manager, the HasanIftakher/Azure-Monitor, tulpy/Azure and gaelor/SentinelAsCode source code examples are useful. See the Azure Resource Manager Example section for further details.