gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 00:45:51 26 4
gpt4 key购买 nike

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

这就是我通过 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 = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2a1adafb2a3acbb82b6a7b0b0a3a4adb0afecabad" rel="noreferrer noopener nofollow">[email protected]</a>"
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",
"origin",
]
}

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

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

关于azure - 如何使用 terraform 在 azure api 管理中的所有 API 级别启用应用程序洞察?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65881679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com