如何使用 terraform 将 Azure 应用程序服务与应用程序洞察资源(新的或现有的)关联?

问题描述 投票:0回答:3

我查看了 azurerm_app_serviceazurerm_application_insights 的文档,但我只是没有找到将它们联系起来的方法。

然而,在门户的“应用服务”页面上,有一个指向“应用程序洞察”的链接,目前呈灰色显示:

那么,如何使用 terraform 启用它?

azure terraform azure-application-insights azure-web-app-service
3个回答
9
投票

您需要进行大量的应用程序设置才能使其按预期正常工作。我必须添加才能使其全部正常工作的是:

  • “APPINSIGHTS_INSTRUMENTATIONKEY”
  • “APPINSIGHTS_PROFILERFEATURE_VERSION”
  • “APPINSIGHTS_SNAPSHOTFEATURE_VERSION”
  • “APPLICATIONINSIGHTS_CONNECTION_STRING”
  • “ApplicationInsightsAgent_EXTENSION_VERSION”
  • “诊断服务_EXTENSION_VERSION”
  • “InstrumentationEngine_EXTENSION_VERSION”
  • “SnapshotDebugger_EXTENSION_VERSION”
  • “XDT_MicrosoftApplicationInsights_BaseExtensions”
  • “XDT_MicrosoftApplicationInsights_Mode”

4
投票

目前似乎还无法使用 Terraform 启用应用程序洞察。有一个功能请求:将 azurerm_application_insights 附加到 Github 中的 azurerm_app_service

可以在

tag
资源上设置
azurerm_application_insights

resource "azurerm_application_insights" "test" {
  tags {
    "hidden-link:/subscriptions/<subscription id>/resourceGroups/<rg name>/providers/Microsoft.Web/sites/<site name>": "Resource"
  }
}

通常,如果您需要在应用程序服务中启用应用程序洞察组件,则需要将

APPINSIGHTS_*
环境变量添加到 Web 应用程序的
app_settings
中。

例如,

 app_settings {
    "APPINSIGHTS_INSTRUMENTATIONKEY" = "${azurerm_application_insights.test.instrumentation_key}"
  }

请参阅参数参考,即使它是关于 Azure 函数的。

参考: https://www.olivercoding.com/2018-06-24-terraform/

https://github.com/terraform-providers/terraform-provider-azurerm/issues/2457


0
投票

有一个关键变量允许特定语言和操作系统版本:

  {
"name": "ApplicationInsightsAgent_EXTENSION_VERSION",
"value": "~3",
"slotSetting": false  }
  1. 值=~2适用于windows APP
  2. 值=~3适用于Linux APP

参考链接: https://learn.microsoft.com/en-us/azure/azure-monitor/app/azure-web-apps-nodejs?tabs=windows

© www.soinside.com 2019 - 2024. All rights reserved.