【问题标题】:How to get Application Insights Application ID when deploying using ARM template?使用 ARM 模板部署时如何获取 Application Insights 应用程序 ID?
【发布时间】:2020-10-16 13:24:17
【问题描述】:

我有一个将 Application Insights 部署到 Azure 的 ARM 模板。

我需要从那里获取“应用程序 ID”

“Application Insights 资源的应用程序 ID 正在监视您在发布流中部署的服务。在 API 访问刀片中找到它”

【问题讨论】:

    标签: azure azure-application-insights arm-template


    【解决方案1】:

    将这样的输出添加到您的模板中:

        "outputs": {
            "AppInsightAppId": {
                "type": "String",
                "value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
            }
        }
    

    例如:

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "appInsightsNamePrefix": {
                "defaultValue": "",
                "type": "String"
            }
        },
        "variables": {
            "appInsightsName": "[concat(parameters('appInsightsNamePrefix'), uniqueString(resourceGroup().id))]"
        },
        "resources": [
            {
                "type": "Microsoft.Insights/components",
                "apiVersion": "2014-04-01",
                "name": "[variables('appInsightsName')]",
                "location": "[resourceGroup().location]",
                "kind": "web",
                "properties": {
                    "ApplicationId": "[variables('appInsightsName')]"
                }
            }
        ],
        "outputs": {
            "AppInsightAppId": {
                "type": "String",
                "value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
            }
        }
    }
    

    【讨论】:

    • 您也可以添加 API 密钥吗?还是我需要为此编写 PowerShell?
    • @cpoDesign 据我所知,使用 ARM 无法做到这一点。您将需要使用 PowerShell。
    • thnx 4 你的答案
    猜你喜欢
    • 2017-11-29
    • 2020-08-23
    • 1970-01-01
    • 2021-02-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多