如何通过ARM创建应用洞察信息中心

时间:2019-12-10 10:54:20

标签: azure azure-devops

我们可以通过ARM模板创建应用程序洞察信息中心吗?我需要通过ARM通过仪表板创建应用程序见解。

1 个答案:

答案 0 :(得分:0)

当然可以。

您可以首先遵循此文档来生成您的ARM模板:Programmatically create Azure Dashboards。对我来说,我正在使用此sample structure

在这里,我向您展示了我的简单示例:

Template.json:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "dashboardName": {
      "type": "string"
    }
  },
  "variables": {},
  "resources": [
    {
      "properties": {
        "lenses": {
          "0": {
            "order": 0,
            "parts": {
              "0": {
                "position": {
                  "x": 0,
                  "y": 0,
                  "colSpan": 2,
                  "rowSpan": 1
                },
                "metadata": {
                  "inputs": [
                    {
                      "name": "id",
                      "value": "/subscriptions/daaeef3e-*****-f9d072825/resourcegroups/{resource group name}/providers/microsoft.insights/components/mer1210" #my application insight
                    },
                    {
                      "name": "Version",
                      "value": "1.0"
                    }
                  ],
                  "type": "Extension/AppInsightsExtension/PartType/AspNetOverviewPinnedPart",
                  "asset": {
                    "idInputName": "id",
                    "type": "ApplicationInsights"
                  },
                  "defaultMenuItemId": "overview"
                }
              },
              "1": {
                "position": {
                  "x": 2,
                  "y": 0,
                  "colSpan": 1,
                  "rowSpan": 1
                },
                "metadata": {
                  "inputs": [
                    {
                      "name": "ComponentId",
                      "value": {
                        "Name": "mer1210",
                        "SubscriptionId": "daaeef3e-******-b3df9d072825",
                        "ResourceGroup": "{resource group name}"
                      }
                    },
                    {
                      "name": "Version",
                      "value": "1.0"
                    }
                  ],
                  "type": "Extension/AppInsightsExtension/PartType/ProactiveDetectionAsyncPart",
                  "asset": {
                    "idInputName": "ComponentId",
                    "type": "ApplicationInsights"
                  },
                  "defaultMenuItemId": "ProactiveDetection"
                }
              }
            }
          }
        }
      },
      "metadata": {},
      "apiVersion": "2015-08-01-preview",
      "type": "Microsoft.Portal/dashboards",
      "name": "[parameters('dashboardName')]",
      "location": "westus",
      "tags": {
        "hidden-title": "[parameters('dashboardName')]"
      }
    }
  ]
}

正如您在Template.json文件中看到的那样,我只是在其中指定了一个参数。而且此模板仅指向一个Azure资源:mer1210(我的应用程序见解)。

因此,下一步是将值分配给我的参数dashboardName

Parameter.json:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "dashboardName": {
      "value": "Merlin-12-10"
    }  
  }
}

查看我这一边的部署结果:

enter image description here


只需根据我的示例进行一些更改,例如dashboard名称,您希望其显示在此仪表板上的metadata