Terraform:将诊断设置添加到Azure应用程序服务时出错

Terraform:将诊断设置添加到Azure应用程序服务时出错,terraform,Terraform,请参阅下面我用来添加诊断设置的配置,以将应用程序服务日志发送到日志分析工作区 错误: Can not parse "target_resource_id" as a resource id: Cannot parse Azure ID: parse "azurerm_app_service.webapp[].id": invalid URI for request 2020-11-06T20:19:59.3344089Z 2020-11-06T20:1

请参阅下面我用来添加诊断设置的配置,以将应用程序服务日志发送到日志分析工作区

错误

Can not parse "target_resource_id" as a resource id: Cannot parse Azure ID: parse "azurerm_app_service.webapp[].id": invalid URI for request
2020-11-06T20:19:59.3344089Z 
2020-11-06T20:19:59.3346016Z   on .terraform\modules\web.web\pipeline\app\apsvc\app_hosting.tf line 127, in resource "azurerm_monitor_diagnostic_setting" "example":
2020-11-06T20:19:59.3346956Z  127: resource "azurerm_monitor_diagnostic_setting" "example" {
2020-11-06T20:19:59.3347091Z 

您可以尝试以下方法:

target_resource_id         = azurerm_app_service.webapp["${each.value.location}-${each.value.apsvc_name}"].id
target_resource_id         = "azurerm_app_service.webapp[${each.value.location}-${each.value.apsvc_name}].id"
而不是:


您可以尝试以下方法:

target_resource_id         = azurerm_app_service.webapp["${each.value.location}-${each.value.apsvc_name}"].id
target_resource_id         = "azurerm_app_service.webapp[${each.value.location}-${each.value.apsvc_name}].id"
而不是: