locked
Creating an alam in AI via the arm template won't deploy RRS feed

  • Question

  • I'm having a problem deploying an alarm via the arm template for my web app.

    my alarm arm template looks somthing like this:

        {
          "type": "Microsoft.Insights/metricAlerts",
          "apiVersion": "2018-03-01",
          "name": "[variables('applicationInsightsMetricsName')]",
          "location": "global",
          "dependsOn": [
            "[resourceId('microsoft.insights/components', variables('appInsightsName'))]",
            "[resourceId('microsoft.insights/actionGroups', variables('actionGroupName'))]"
          ],
          "properties": {
            "description": "Monitoring exceptions.",
            "severity": 0,
            "enabled": true,
            "scopes": [
              "[resourceId('microsoft.insights/components', variables('appInsightsName'))]"
            ],
            "evaluationFrequency": "PT1M",
            "windowSize": "PT5M",
            "criteria": {
              "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
            },
            "actions": [
              {
                "actionGroupId": "[resourceId('microsoft.insights/actionGroups', variables('actionGroupName'))]",
                "webHookProperties": {}
              }
            ]
          }
        }

    But when I try to deploy this arm template I get stuck in a internal error loop, for example:

    { "id": "/resourceGroups/LCAICustomerWebsite/providers/Microsoft.Resources/deployments/azuredeploy-0829-0838/operations/81D2FF6BDD46B27D", "operationId": "81D2FF6BDD46B27D", "properties": { "provisioningOperation": "Create", "provisioningState": "Running", "timestamp": "2019-08-29T09:04:18.7978094Z", "duration": "PT25M39.1601519S", "trackingId": "3ccc1d6c-f2d5-433b-9873-876da3873286", "statusCode": "InternalServerError", "statusMessage": { "error": { "code": "InternalServerError", "message": "The server encountered an internal error, please retry. If the problem persists, contact support." } }, "targetResource": { "id": "/subscriptions/08bc1d04-fc5c-488a-818c-00a57d951e9e/resourceGroups/LCAICustomerWebsite/providers/Microsoft.Insights/metricAlerts/LCTC-Web-devRequestsAlert", "resourceType": "Microsoft.Insights/metricAlerts", "resourceName": "LCTC-Web-devRequestsAlert" } }}

    Which have the error:

    {
    "authorization": {
    "action": "Microsoft.Insights/metricAlerts/write",
    "scope": "XXX/resourcegroups/LCAICustomerWebsite/providers/Microsoft.Insights/metricAlerts/LCTC-Web-devExceptionsAlert"
    },
    "caller": "XXX",
    "channels": "Operation",
    "claims": {
    "aud": "https://management.core.windows.net/",
    "iss": "https://sts.windows.net/192d7c93-1ae9-4fbd-872c-9e59ca31cffa/",
    "iat": "1567067584",
    "nbf": "1567067584",
    "exp": "1567071484",
    "http://schemas.microsoft.com/claims/authnclassreference": "1",
    "aio": "AVQAq/8MAAAAQGvJD3j+8bMsAHaqKFT9cT7alQsAr3YULqipLAs9/VBSYyKEYOR3tLtPIkRIF3KuNPlOG0AJALILvWI/FuTh/6dS1Z1y883PKjNtn/vhU7o=",
    "http://schemas.microsoft.com/claims/authnmethodsreferences": "pwd,mfa",
    "appid": "872cd9fa-d31f-45e0-9eab-6e460a02d1f1",
    "appidacr": "0",
    "http://schemas.microsoft.com/2012/01/devicecontext/claims/identifier": "894c3f62-a625-45c1-b62f-af03bf3bae1f",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname": "XXX",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname": "XXX",
    "ipaddr": "185.213.105.179",
    "name": "XXX",
    "http://schemas.microsoft.com/identity/claims/objectidentifier": "619efd45-dff5-4d15-82cf-ec1c683b260b",
    "puid": "10032000409026E5",
    "http://schemas.microsoft.com/identity/claims/scope": "user_impersonation",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "xsNpU2x5Rx6XWd6xNfOiPD8n3ISNisAIxayRWqKbDlg",
    "http://schemas.microsoft.com/identity/claims/tenantid": "192d7c93-1ae9-4fbd-872c-9e59ca31cffa",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name": "XXX",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn": "XXX",
    "uti": "P6iPLR9HIU6VQq3p5R8XAA",
    "ver": "1.0"
    },
    "correlationId": "1a1e754c-3bfb-4b56-aacc-c9b3db386925",
    "description": "",
    "eventDataId": "e71d9c2d-a81f-432e-83f6-f75c6c4dc8e8",
    "eventName": {
    "value": "EndRequest",
    "localizedValue": "End request"
    },
    "category": {
    "value": "Administrative",
    "localizedValue": "Administrative"
    },
    "eventTimestamp": "2019-08-29T08:42:46.4718748Z",
    "id": "/resourcegroups/LCAICustomerWebsite/providers/Microsoft.Insights/metricAlerts/LCTC-Web-devExceptionsAlert/events/e71d9c2d-a81f-432e-83f6-f75c6c4dc8e8/ticks/637026649664718748",
    "level": "Error",
    "operationId": "d116dbfd-2507-418a-93b1-719838944541",
    "operationName": {
    "value": "Microsoft.Insights/metricAlerts/write",
    "localizedValue": "Create or update metric alert"
    },
    "resourceGroupName": "LCAICustomerWebsite",
    "resourceProviderName": {
    "value": "Microsoft.Insights",
    "localizedValue": "Microsoft Insights"
    },
    "resourceType": {
    "value": "Microsoft.Insights/metricAlerts",
    "localizedValue": "Microsoft.Insights/metricAlerts"
    },
    "resourceId": "/resourcegroups/LCAICustomerWebsite/providers/Microsoft.Insights/metricAlerts/LCTC-Web-devExceptionsAlert",
    "status": {
    "value": "Failed",
    "localizedValue": "Failed"
    },
    "subStatus": {
    "value": "InternalServerError",
    "localizedValue": "Internal Server Error (HTTP Status Code: 500)"
    },
    "submissionTimestamp": "2019-08-29T08:43:41.1033205Z",
    "subscriptionId": "XXX",
    "properties": {
    "statusCode": "InternalServerError",
    "serviceRequestId": "d116dbfd-2507-418a-93b1-719838944541",
    "statusMessage": "{\"error\":{\"code\":\"InternalServerError\",\"message\":\"The server encountered an internal error, please retry. If the problem persists, contact support.\"}}"
    },
    "relatedEvents": []
    }




    • Edited by LironLevy Thursday, August 29, 2019 9:41 AM
    Thursday, August 29, 2019 9:02 AM

All replies

  • Liron,

    Are you still getting this error or was it a transient issue?

    I have not been able to reproduce the error but I am engaging with internal resources to see if we can determine the root cause.

    I will let you know if there is any additional info that would be helpful in the diagnosis.

    Monday, September 2, 2019 8:26 PM
  • Liron,

    According to the product team they are working on fixing the error message to return something useful as well as the fact that the "allOf" property is missing from exported templates.

    Here is the correct template format: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/alerts-metric-create-templates#template-for-a-simple-static-threshold-metric-alert

    For your template, here is the property you need to add:

    "allOf": [
    	{
    	"dimensions": [
    		{
    			"name": "cloud/roleName",
    			"operator": "Include",
    			"values": [
    				"lcai-web-dev"
    			]
    		}
    	],
    	"metricName": "exceptions/count",
    	"metricNamespace": "microsoft.insights/components",
    	"monitorTemplateType": 8,
    	"name": "Metric1",
    	"operator": "GreaterThanOrEqual",
    	"threshold": 1.0,
    	"timeAggregation": "Count"
    }]


    Wednesday, September 4, 2019 3:27 PM