azure - 为什么自动发布后需要手动开启App Insights?

标签 azure azure-devops azure-resource-manager appinsights

为什么应用洞察在发布后没有自动开启?

执行自动发布后,我在导航到门户中的应用洞察时收到以下信息:

enter image description here

以下是我在 ARM 模板中定义的方式:

{
  "type": "microsoft.insights/components",
  "kind": "web",
  "name": "[parameters('webAppName')]",
  "apiVersion": "2015-05-01",
  "location": "[parameters('location')]",
  "tags": {
    "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', parameters('webAppName'))]": "Resource",
    "displayName": "[parameters('webAppName')]"
  },
  "properties": {
    "Application_Type": "web"
  },
  "dependsOn": []
}

我做错了什么? 为什么应用洞察没有自动开启?

请注意,我添加了以下应用程序设置:

enter image description here

最佳答案

为了让 Azure 门户显示与 Application Insights 的主动集成,您需要设置两个应用设置。原因是您还需要配置 Application Insights Agent Extension。

请注意,设置 InstrumentationKey(已弃用)或连接字符串可能足以让您的应用程序将遥测数据发送到 ApplicationInsights,例如如果您使用的是 ASP.NET Core 和相应的 Nuget 包。但您将需要门户的这两种设置才能显示事件的集成。

{
    "resources": [
        {
            "name": "[parameters('name')]",
            "type": "Microsoft.Web/sites",
            "properties": {
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
                            "value": "[reference('microsoft.insights/components/AppMonitoredSite', '2015-05-01').ConnectionString]"
                        },
                        {
                            "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                            "value": "~2"
                        }
                    ]
                },
                "name": "[parameters('name')]",
                "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
                "hostingEnvironment": "[parameters('hostingEnvironment')]"
            },
            "dependsOn": [
                "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
                "microsoft.insights/components/AppMonitoredSite"
            ],
            "apiVersion": "2016-03-01",
            "location": "[parameters('location')]"
        },
        {
            "apiVersion": "2016-09-01",
            "name": "[parameters('hostingPlanName')]",
            "type": "Microsoft.Web/serverfarms",
            "location": "[parameters('location')]",
            "properties": {
                "name": "[parameters('hostingPlanName')]",
                "workerSizeId": "[parameters('workerSize')]",
                "numberOfWorkers": "1",
                "hostingEnvironment": "[parameters('hostingEnvironment')]"
            },
            "sku": {
                "Tier": "[parameters('sku')]",
                "Name": "[parameters('skuCode')]"
            }
        },
        {
            "apiVersion": "2015-05-01",
            "name": "AppMonitoredSite",
            "type": "microsoft.insights/components",
            "location": "West US 2",
            "properties": {
                "ApplicationId": "[parameters('name')]",
                "Request_Source": "IbizaWebAppExtensionCreate"
            }
        }
    ],
    "parameters": {
        "name": {
            "type": "string"
        },
        "hostingPlanName": {
            "type": "string"
        },
        "hostingEnvironment": {
            "type": "string"
        },
        "location": {
            "type": "string"
        },
        "sku": {
            "type": "string"
        },
        "skuCode": {
            "type": "string"
        },
        "workerSize": {
            "type": "string"
        },
        "serverFarmResourceGroup": {
            "type": "string"
        },
        "subscriptionId": {
            "type": "string"
        }
    },
    "$schema": "https://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0"
}

另请参阅我对此的其他回答:Azure Cli How to enable Application Insights for webapp

编辑:根据 BearOak​​heart 答案中的新信息进行更新。

关于azure - 为什么自动发布后需要手动开启App Insights?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65343991/

相关文章:

Azure DevOps,设置依赖于多个作业的作业

Azure Bicep - 如果使用相同模板进行部署时显示资源更改的命令会怎样

azure - 如何测试链接的ARM模板?

linq - 从 "LINQ to SQL"到 "Azure Table Storage"或 "SQL Data Service"

azure-devops - 覆盖状态检查失败?

azure - 如何在Azure管道任务中创建对象并将其作为变量返回以在其他任务中使用?

azure - 如何将 azure 链接的 VSTS/DevOps 移动到另一个帐户/azure 订阅

azure - 获取 ARM 中逻辑应用的回调 url

azure - 如何为个人访问 token 设置 Databricks Unity 目录的读取权限?

asp.net - 为什么应用程序也会命中本地 ADFS?