将 arm 模板部署到 azure 时出现内部服务器错误

Internal server error while deploying an arm template to azure

我正在使用 ARM 模板将新的指标警报部署到 Azure。 我遵循与 Microsoft doc 完全相同的方式。 唯一的变化是我只将 1 个指标部署到自动化帐户而不是存储帐户

模板文件

  "variables": {
    "criterion1": "[array(parameters('criterion1'))]",
    "criteria": "[concat(variables('criterion1'))]"
 
  
},
"resources": [
    {
        "name": "[parameters('alertName')]",
        "type": "Microsoft.Insights/metricAlerts",
        "location": "global",
        "apiVersion": "2018-03-01",
        "tags": {},
        "properties": {
            "description": "[parameters('alertDescription')]",
            "severity": "[parameters('alertSeverity')]",
            "enabled": "[parameters('isEnabled')]",
            "scopes": [
                "[parameters('resourceId')]"
            ],
            "evaluationFrequency": "[parameters('evaluationFrequency')]",
            "windowSize": "[parameters('windowSize')]",
            "criteria": {
                "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
                "allOf": "[variables('criteria')]"
            },
            "actions": [
                {}
            ]
        }
    }
]

参数文件

  "criterion1": {
            "value": {
                "name": "1st criterion",
                "metricName": "TotalJob",
                "dimensions": [
                    {
                        "name": "Status",
                        "operator": "Include",
                        "values": [
                            "Failed"
                        ]
                    },
                    {
                        "name": "Status",
                        "operator": "Include",
                        "values": [
                            "Completed"
                        ]
                    }
                ],
                "operator": "GreaterThan",
                "threshold": "5",
                "timeAggregation": "Total"
            }
        }

但是,当我将它部署到 Azure 时,我的 Powershell 命令卡住了,没有给出任何错误,即使上面有 -DeploymentDebugLogLevel All 参数也是如此。在 Azure 门户中,我收到没有任何上下文的错误“内部服务器错误”。 json 日志为我提供了以下日志:

{
"authorization": {
    "action": "Microsoft.Insights/metricAlerts/write",
    "scope": "/subscriptions/xxxxxx/resourcegroups/bilalachahbar/providers/Microsoft.Insights/metricAlerts/New Metric Alert"
},
"caller": "xxxx",
"channels": "Operation",
"claims": {
    "aud": "https://management.azure.com/",
    "iss": "https://sts.windows.net/17b5a1d-057c-4ac-a15a-08758f7a7064/",
    "iat": "15596014",
    "nbf": "15596014",
    "exp": "15599914",
    "aio": "42RgYDgypS7rfe/Of0l1R+q3TbCgA=",
    "appid": "0e4a093a-c6fd-4fba-b4e5-f07ba479f203",
    "appidacr": "1",
    "http://schemas.microsoft.com/identity/claims/identityprovider": "https://sts.windows.net/17xxxxxc5-a15a-08758f7a7064/",
    "http://schemas.microsoft.com/identity/claims/objectidentifier": "a3db39bf-8c65-4b84-b049-d7af99bfb3e",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "a3db39bf-8c65-4b84-b049-d7af99bfb3e",
    "http://schemas.microsoft.com/identity/claims/tenantid": "1xxxxxx057c-4ac5-a15a-087f7a7064",
    "uti": "SCkIk235EScz0Hst20AA",
    "ver": "1.0"
},
"correlationId": "8013b5-9788-41ed-afcf-0dbd8276349c",
"description": "",
"eventDataId": "e39509-0837-4435-af7a-02ba1462055f",
"eventName": {
    "value": "EndRequest",
    "localizedValue": "End request"
},
"category": {
    "value": "Administrative",
    "localizedValue": "Administrative"
},
"eventTimestamp": "2018-12-27T14:11:48.1462445Z",
"id": "/subscriptions/xxxxx/resourcegroups/xxxxxx/providers/Microsoft.Insights/metricAlerts/New+Metric+Alert/events/e39509-0837-4435-af7a-02ba1462055f/ticks/815167081462445",
"level": "Error",
"operationId": "e390389-ecc1-4a2-8c2-d94ea635cb",
"operationName": {
    "value": "Microsoft.Insights/metricAlerts/write",
    "localizedValue": "Create or update metric alert"
},
"resourceGroupName": "xxxxx",
"resourceProviderName": {
    "value": "Microsoft.Insights",
    "localizedValue": "Microsoft Insights"
},
"resourceType": {
    "value": "Microsoft.Insights/metricAlerts",
    "localizedValue": "Microsoft.Insights/metricAlerts"
},
"resourceId": "/subscriptions/xxxxxx/resourcegroups/bilalachahbar/providers/Microsoft.Insights/metricAlerts/New Metric Alert",
"status": {
    "value": "Failed",
    "localizedValue": "Failed"
},
"subStatus": {
    "value": "InternalServerError",
    "localizedValue": "Internal Server Error (HTTP Status Code: 500)"
},
"submissionTimestamp": "2018-12-27T14:12:05.0719055Z",
"subscriptionId": "xxxxxx",
"properties": {
    "statusCode": "InternalServerError",
    "serviceRequestId": "8613b5-9788-41d-afcf-0dbd27639c",
    "statusMessage": "{\"error\":{\"code\":\"InternalServerError\",\"message\":\"The server encountered an internal error, please retry. If the problem persists, contact support.\"}}"
},
"relatedEvents": []

}

另一个 问题得到了类似的问题。 他在使用不再受支持的资源时遇到了问题,但我想我的情况并非如此,因为官方 MS 文档是从今年 9 月开始的。当我使用文档中提供的完全相同的 arm 模板时,我遇到了同样的问题

我发现了我自己的错误 当您想要部署指标警报时,需要操作组。 正如您在文档中看到的那样,他们提供了一个操作 ID,而我没有。因为我认为没有必要,它实际上是。 我知道这很明显,但不幸的是我没有在文档或错误中看到这一点。经过一些调试并查看资源浏览器后,我注意到了这一点。 所以未来 reader 我希望这会解决你的问题

一个小反馈是没有依赖值ATM所以我不能在同一个arm模板中先创建一个action group资源