Azure API Management API Operation

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

azurerm_api_management_api_operation (Terraform)

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

Example Usage from GitHub

api-management-main.tf#L46
resource "azurerm_api_management_api_operation" "Configurations-post" {
  method       = "POST"
  url_template = "/*"
  // ... other properties
  api_management_name = azurerm_api_management.demo-apim.name
  api_name            = azurerm_api_management_api.demo-users-api.name
commerce-api.tf#L15
resource "azurerm_api_management_api_operation" "commerce_get" {
  operation_id        = "commerce-get"
  api_name            = azurerm_api_management_api.commerce.name
  api_management_name = azurerm_api_management.this.name
  resource_group_name = azurerm_resource_group.this.name

resource.tf#L1
resource "azurerm_api_management_api_operation" "api_operation" {
  count               = length(var.res_api_operation)
  operation_id        = var.res_api_operation[count.index].operationid
  api_name            = var.res_api_name
  api_management_name = var.res_apim_name
  resource_group_name = var.res_rg_name
api.tf#L16
resource "azurerm_api_management_api_operation" "operation1" {
  operation_id        = "user-get"
  api_name            = azurerm_api_management_api.composite-api.name
  api_management_name = azurerm_api_management.apim.name
  resource_group_name = azurerm_resource_group.rg.name
  display_name        = "Get User Operation"
main.tf#L6
resource "azurerm_api_management_api_operation" "apim_api_operation" {
  operation_id = var.operation_id == "" ? random_string.random.result : var.operation_id

  api_name            = var.api_mgmt_api_name
  api_management_name = var.api_mgmt_name
  resource_group_name = var.api_mgmt_rg
sampleOperationsOutput.tf#L1
resource "azurerm_api_management_api_operation" "GetHouseholdAsync" {
  operation_id        = "gethouseholdasync"
  api_name            = azurerm_api_management_api.usersapiv1.name
  api_management_name = azurerm_api_management_api.usersapiv1.api_management_name
  resource_group_name = azurerm_api_management_api.usersapiv1.resource_group_name
  display_name        = "GetHouseholdAsync(Guid householdId)"
health_check.tf#L12
resource "azurerm_api_management_api_operation" "apim" {
  operation_id        = "liveness-check"
  api_name            = azurerm_api_management_api.apim.name
  api_management_name = data.azurerm_api_management.apim.name
  resource_group_name = var.virtual_network_resource_group
  display_name        = "Liveness check"
api_operation.tf#L1
resource "azurerm_api_management_api_operation" "api_operation" {
  operation_id        = var.operation_id
  api_name            = var.apima_name
  api_management_name = var.apim_name
  resource_group_name = var.resource_group_name
  display_name        = var.display_name
main.tf#L1
resource "azurerm_api_management_api_operation" "op" {
  operation_id        = var.operation_id
  api_name            = var.api_name
  api_management_name = var.apim_name
  resource_group_name = var.resource_group_name
  display_name        = var.display_name
commerce-auth-api.tf#L15
resource "azurerm_api_management_api_operation" "commerce_auth_post" {
  operation_id        = "commerce-auth-post"
  api_name            = azurerm_api_management_api.commerce_auth.name
  api_management_name = azurerm_api_management.this.name
  resource_group_name = azurerm_resource_group.this.name

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 Operation within an API Management Service.

Microsoft.ApiManagement/service/apis/operations (Azure Resource Manager)

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

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

  • apiVersion required - string
  • name required - string

    Operation identifier within an API. Must be unique in the current API Management service instance.

  • properties required
      • description optional - string

        Description of the operation. May include HTML formatting tags.

      • displayName required - string

        Operation Name.

      • method required - string

        A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them.

      • policies optional - string

        Operation Policies

      • request optional
          • description optional - string

            Operation request description.

          • headers optional array
              • defaultValue optional - string

                Default parameter value.

              • description optional - string

                Parameter description.

              • examples optional - undefined

                Parameter examples.

              • name required - string

                Parameter name.

              • required optional - boolean

                Specifies whether parameter is required or not.

              • schemaId optional - string

                Schema identifier.

              • type required - string

                Parameter type.

              • typeName optional - string

                Type name defined by the schema.

              • values optional - array

                Parameter values.

          • queryParameters optional array
              • defaultValue optional - string

                Default parameter value.

              • description optional - string

                Parameter description.

              • examples optional - undefined

                Parameter examples.

              • name required - string

                Parameter name.

              • required optional - boolean

                Specifies whether parameter is required or not.

              • schemaId optional - string

                Schema identifier.

              • type required - string

                Parameter type.

              • typeName optional - string

                Type name defined by the schema.

              • values optional - array

                Parameter values.

          • representations optional array
              • contentType required - string

                Specifies a registered or custom content type for this representation, e.g. application/xml.

              • examples optional - undefined

                Parameter examples.

              • formParameters optional array
                  • defaultValue optional - string

                    Default parameter value.

                  • description optional - string

                    Parameter description.

                  • examples optional - undefined

                    Parameter examples.

                  • name required - string

                    Parameter name.

                  • required optional - boolean

                    Specifies whether parameter is required or not.

                  • schemaId optional - string

                    Schema identifier.

                  • type required - string

                    Parameter type.

                  • typeName optional - string

                    Type name defined by the schema.

                  • values optional - array

                    Parameter values.

              • schemaId optional - string

                Schema identifier. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'.

              • typeName optional - string

                Type name defined by the schema. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'.

      • responses optional array
          • description optional - string

            Operation response description.

          • headers optional array
              • defaultValue optional - string

                Default parameter value.

              • description optional - string

                Parameter description.

              • examples optional - undefined

                Parameter examples.

              • name required - string

                Parameter name.

              • required optional - boolean

                Specifies whether parameter is required or not.

              • schemaId optional - string

                Schema identifier.

              • type required - string

                Parameter type.

              • typeName optional - string

                Type name defined by the schema.

              • values optional - array

                Parameter values.

          • representations optional array
              • contentType required - string

                Specifies a registered or custom content type for this representation, e.g. application/xml.

              • examples optional - undefined

                Parameter examples.

              • formParameters optional array
                  • defaultValue optional - string

                    Default parameter value.

                  • description optional - string

                    Parameter description.

                  • examples optional - undefined

                    Parameter examples.

                  • name required - string

                    Parameter name.

                  • required optional - boolean

                    Specifies whether parameter is required or not.

                  • schemaId optional - string

                    Schema identifier.

                  • type required - string

                    Parameter type.

                  • typeName optional - string

                    Type name defined by the schema.

                  • values optional - array

                    Parameter values.

              • schemaId optional - string

                Schema identifier. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'.

              • typeName optional - string

                Type name defined by the schema. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'.

          • statusCode required - integer

            Operation response HTTP status code.

      • templateParameters optional array
          • defaultValue optional - string

            Default parameter value.

          • description optional - string

            Parameter description.

          • examples optional - undefined

            Parameter examples.

          • name required - string

            Parameter name.

          • required optional - boolean

            Specifies whether parameter is required or not.

          • schemaId optional - string

            Schema identifier.

          • type required - string

            Parameter type.

          • typeName optional - string

            Type name defined by the schema.

          • values optional - array

            Parameter values.

      • urlTemplate required - string

        Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}

  • type required - string

Frequently asked questions

What is Azure API Management API Operation?

Azure API Management API Operation 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 Operation?

For Terraform, the ElAouaneHamza/Private-endpoint-conf, madsstorm/terraform-commercetools-azure-sample and avishekansible/AzureLandingZone source code examples are useful. See the Terraform Example section for further details.