如何使用Arm模板在应用程序洞察中启用Sql Command跟踪

时间:2019-08-02 14:31:58

标签: azure-application-insights arm-template

我们开始使用应用程序见解来跟踪我们的性能。 我在手臂模板中找到了一些示例,并设法做到这些:

           {
              "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
              "value": "[reference(variables('appInsightsResourceID'), '2015-05-01').InstrumentationKey]"
            },
            {
              "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
              "value": "~2"
            },
            {
              "name": "DiagnosticServices_EXTENSION_VERSION",
              "value": "~3"
            },
            {
              "name": "APPINSIGHTS_PROFILERFEATURE_VERSION",
              "value": "1.0.0"
            }

这似乎启用了探查器,禁用了快照调试器,并且“建议”具有收集级别。

但是,如果要启用Sql命令跟踪,该怎么办?我找不到示例,并且如果我导出模板,似乎没有与导出应用程序见解相关的设置。

2 个答案:

答案 0 :(得分:3)

您可以尝试设置这两个属性以及现有属性吗?

"Properties": {
        "InstrumentationEngine_EXTENSION_VERSION": "~1",
        "XDT_MicrosoftApplicationInsights_BaseExtensions": "~1"
}

答案 1 :(得分:0)

在创建Web App之前,您可以通过单击下载用于自动化的模板”选项找到具有这些设置的ARM模板。稍后您可以根据需要在其中进行设置。以下模板和设置对我有用,并包括@bit上面指出的属性:

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "subscriptionId": {
        "type": "string"
    },
    "name": {
        "type": "string"
    },
    "location": {
        "type": "string"
    },
    "hostingEnvironment": {
        "type": "string"
    },
    "hostingPlanName": {
        "type": "string"
    },
    "serverFarmResourceGroup": {
        "type": "string"
    },
    "alwaysOn": {
        "type": "bool"
    },
    "currentStack": {
        "type": "string"
    }
},
"resources": [
    {
        "apiVersion": "2018-02-01",
        "name": "[parameters('name')]",
        "type": "Microsoft.Web/sites",
        "location": "[parameters('location')]",
        "tags": {},
        "dependsOn": [],
        "properties": {
            "name": "[parameters('name')]",
            "siteConfig": {
                "appSettings": [
                    {
                        "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                        "value": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    },
                    {
                        "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                        "value": "~2"
                    },
                    {
                        "name": "XDT_MicrosoftApplicationInsights_Mode",
                        "value": "recommended"
                    },
                    {
                        "name": "DiagnosticServices_EXTENSION_VERSION",
                        "value": "~3"
                    },
                    {
                        "name": "APPINSIGHTS_PROFILERFEATURE_VERSION",
                        "value": "1.0.0"
                    },
                    {
                        "name": "APPINSIGHTS_SNAPSHOTFEATURE_VERSION",
                        "value": "disabled"
                    },
                    {
                        "name": "InstrumentationEngine_EXTENSION_VERSION",
                        "value": "~1"
                    },
                    {
                        "name": "SnapshotDebugger_EXTENSION_VERSION",
                        "value": "disabled"
                    },
                    {
                        "name": "XDT_MicrosoftApplicationInsights_BaseExtensions",
                        "value": "~1"
                    }
                ],
                "metadata": [
                    {
                        "name": "CURRENT_STACK",
                        "value": "[parameters('currentStack')]"
                    }
                ],
                "alwaysOn": "[parameters('alwaysOn')]"
            },
            "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
            "hostingEnvironment": "[parameters('hostingEnvironment')]",
            "clientAffinityEnabled": true
        }
    }
]

}

部署此模板会为我提供具有以下配置的App Service:

enter image description here

查看this文档以了解上述使用的应用程序设置定义。

希望这会有所帮助!