I'm using ARM templates to deploy resources in Azure but I'd like to deploy alerts at the same time. This case is about an Azure Function.
I first created the Http5xx alert in the portal and then used the Azure Resource Manager to lookup the template to be used:
{
"type": "Microsoft.Insights/alertRules",
"name": "Http Server Error",
"apiVersion": "2014-04-01",
"location": "[resourceGroup().Location]",
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Web/sites', parameters('functionName')))]": "Resource"
},
"scale": null,
"properties": {
"name": "Http Server Error",
"description": "Raise alert when the function returns HTTP 5xx error",
"isEnabled": true,
"condition": {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[resourceId('Microsoft.Web/sites', parameters('functionName'))]",
"resourceLocation": null,
"metricNamespace": null,
"metricName": "Http5xx",
"legacyResourceId": null
},
"operator": "GreaterThan",
"threshold": 1,
"windowSize": "PT5M",
"timeAggregation": "Total"
},
"actions": [
{
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleWebhookAction, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction",
"serviceUri": "https://some-awesome-webhook",
"properties": {
"$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary`1[[System.String, mscorlib]], Microsoft.WindowsAzure.Management.Common.Storage"
}
}
]
}
}
In the middle you can see the 'metricName' with value 'Http5xx'. Now when I run this as part of my ARM template, it fails with this message:
{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.",
"details": [
{
"code": "BadRequest",
"message": "{\r\n \"code\": \"UnsupportedMetric\",\r\n \"message\": \"The metric with namespace '' and name 'Http5xx' is not supported for this resource id '/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/my-awesome-rg/providers/Microsoft.Web/sites/my-awesome-function'.\"\r\n}"
}
]
}
]
}
}
It basically says my Http5xx is not supported for Functions, but in this documentation it states this metric is supported: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics
Anyone an idea what I'm doing wrong?