Azure API Management API Diagnostic

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

azurerm_api_management_api_diagnostic (Terraform)

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

Example Usage from GitHub

api-diagnostic.tf#L1
resource "azurerm_api_management_api_diagnostic" "this" {
  identifier               = "applicationinsights"
  resource_group_name      = var.resource_group_name
  api_management_name      = var.api_management_name
  api_name                 = var.api_name
  api_management_logger_id = var.api_management_logger_id
27-api-management-api-diagnostic.tf#L1
resource "azurerm_api_management_api_diagnostic" "hmi_apim_diag" {
  resource_group_name      = azurerm_resource_group.hmi_apim_rg.name
  api_management_name      = azurerm_api_management.hmi_apim.name
  api_name                 = azurerm_api_management_api.hmi_apim_api.name
  api_management_logger_id = azurerm_api_management_logger.hmi_apim_logger.id
  identifier               = "applicationinsights"
27-api-management-api-diagnostic.tf#L1
resource "azurerm_api_management_api_diagnostic" "pip_apim_diag" {
  resource_group_name      = azurerm_resource_group.pip_apim_rg.name
  api_management_name      = azurerm_api_management.pip_apim.name
  api_name                 = azurerm_api_management_api.pip_apim_api.name
  api_management_logger_id = azurerm_api_management_logger.pip_apim_logger.id
  identifier               = "applicationinsights"
main.tf#L18
resource "azurerm_api_management_api_diagnostic" "api" {

  identifier               = "applicationinsights"
  resource_group_name      = var.context.resource_group_name
  api_management_name      = var.service_settings.endpoint_name
  api_name                 = azurerm_api_management_api.api.name
apima.tf#L24
resource "azurerm_api_management_api_diagnostic" "api_diagnostic" {
  resource_group_name       = var.resource_group_name
  api_management_name       = var.api_management_name
  api_name                  = azurerm_api_management_api.api.name
  api_management_logger_id  = azurerm_api_management_logger.apim_logger.id
  identifier                = "applicationinsights"
main.tf#L26
resource "azurerm_api_management_api_diagnostic" "diagnostic" {
  for_each                 = toset(var.api_names)
  identifier               = "applicationinsights"
  resource_group_name      = var.resource_group_name
  api_management_name      = var.api_management_name
  api_name                 = each.key

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 a API Management Service API Diagnostics Logs.

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

The service/apis/diagnostics in Microsoft.ApiManagement can be configured in Azure Resource Manager with the resource name Microsoft.ApiManagement/service/apis/diagnostics. 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

    Diagnostic identifier. Must be unique in the current API Management service instance.

  • properties required
      • alwaysLog optional - string

        Specifies for what type of messages sampling settings should not apply.

      • backend optional
          • request optional
              • body optional
                  • bytes optional - integer

                    Number of request body bytes to log.

              • dataMasking optional
                  • headers optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

                  • queryParams optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

              • headers optional - array

                Array of HTTP Headers to log.

          • response optional
              • body optional
                  • bytes optional - integer

                    Number of request body bytes to log.

              • dataMasking optional
                  • headers optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

                  • queryParams optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

              • headers optional - array

                Array of HTTP Headers to log.

      • frontend optional
          • request optional
              • body optional
                  • bytes optional - integer

                    Number of request body bytes to log.

              • dataMasking optional
                  • headers optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

                  • queryParams optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

              • headers optional - array

                Array of HTTP Headers to log.

          • response optional
              • body optional
                  • bytes optional - integer

                    Number of request body bytes to log.

              • dataMasking optional
                  • headers optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

                  • queryParams optional array
                      • mode optional - string

                        Data masking mode.

                      • value optional - string

                        The name of an entity to mask (e.g. a name of a header or a query parameter).

              • headers optional - array

                Array of HTTP Headers to log.

      • httpCorrelationProtocol optional - string

        Sets correlation protocol to use for Application Insights diagnostics.

      • logClientIp optional - boolean

        Log the ClientIP. Default is false.

      • loggerId required - string

        Resource Id of a target logger.

      • operationNameFormat optional - string

        The format of the Operation Name for Application Insights telemetries. Default is Name.

      • sampling optional
          • percentage optional - number

            Rate of sampling for fixed-rate sampling.

          • samplingType optional - string

            Sampling type.

      • verbosity optional - string

        The verbosity level applied to traces emitted by trace policies.

  • type required - string

Frequently asked questions

What is Azure API Management API Diagnostic?

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

For Terraform, the madsstorm/terraform-commercetools-azure-sample, hmcts/hmi-api-gateway-fh and hmcts/pip-api-gateway source code examples are useful. See the Terraform Example section for further details.