Showing posts with label AppService. Show all posts
Showing posts with label AppService. Show all posts

Saturday, January 18, 2020

             Alert scope is invalid in WebTests under Azure AppService availability  



Hi Folks,

While  working on Azure ARM for WebTests in AppInsights i confronted an error states "Alert scope is invalid"

Use Case: I created ARM template to deploy WebTests for verify an availability of a AppService.
Special thing is ARM also contains inner template for Alert .
When i push through Deployment centre in Azure portal or through powershell i received below error.

New-AzureRmResourceGroupDeployment : 13:26:47 - Resource microsoft.insights/metricalerts 'xxx' failed with message '{
  "Code": "BadRequest",
  "Message": "Alert scope is invalid."
}'

After struggling a lot i found a solution here ,You just require add  componentId,failedLocationCount and webTestId.


 "criteria":{
                     "odata.type":"Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
                     "componentId":"[resourceId('microsoft.insights/components'variables('applicationInsightName'))]",
                     "failedLocationCount":2,
                     "webTestId":"[resourceId('microsoft.insights/webtests'variables('appAvailability'))]"
                  }

As soon as you add an above content you should be able to resolve an error.


Happy Coding,

#Azure #ARMTemplate #AzureAlerts