微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 terraform 在 azure api 管理中启用所有 API 级别的应用程序洞察?

如何解决如何使用 terraform 在 azure api 管理中启用所有 API 级别的应用程序洞察?

我正在使用 terraform 管理我的 azure API 管理(API 和策略)。 大多数事情都运行良好,https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs 上的文档很棒。 但是现在我需要在 error 级别激活具有详细程度 All-APIs 的应用程序洞察诊断日志。不幸的是,我不明白如何通过检查文档来做到这一点。有人可以帮我怎么做吗?

这是我通过 UI 设置时的样子。

this is what I want to achieve with terraform

希望有人能帮忙?

解决方法

azurerm_api_management_diagnostic 应该是您要找的

resource "azurerm_application_insights" "example" {
  name                = "example-appinsights"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  application_type    = "web"
}

resource "azurerm_api_management" "example" {
  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"
  sku_name            = "Developer_1"
}
resource "azurerm_api_management_logger" "example" {
  name                = "example-apimlogger"
  api_management_name = azurerm_api_management.example.name
  resource_group_name = azurerm_resource_group.example.name

  application_insights {
    instrumentation_key = azurerm_application_insights.example.instrumentation_key
  }
}

resource "azurerm_api_management_diagnostic" "example" {
  identifier               = "applicationinsights"
  resource_group_name      = azurerm_resource_group.example.name
  api_management_name      = azurerm_api_management.example.name
  api_management_logger_id = azurerm_api_management_logger.example.id

  sampling_percentage       = 5.0
  always_log_errors         = true
  log_client_ip             = true
  verbosity                 = "Verbose"
  http_correlation_protocol = "W3C"

  frontend_request {
    body_bytes = 32
    headers_to_log = [
      "content-type","accept","origin",]
  }

  frontend_response {
    body_bytes = 32
    headers_to_log = [
      "content-type","content-length",]
  }

  backend_request {
    body_bytes = 32
    headers_to_log = [
      "content-type",]
  }

  backend_response {
    body_bytes = 32
    headers_to_log = [
      "content-type",]
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。