我正在使用ARM模板在Azure中部署资源,但我想部署 同时发出警报。本案例涉及Azure功能。
我首先在门户中创建了Http5xx警报,然后使用Azure资源管理器查找要使用的模板:
{
"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"
}
}
]
}
}
在中间你可以看到'metricName',其值为'Http5xx'。 现在,当我将其作为ARM模板的一部分运行时,它会失败并显示以下消息:
{
"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}"
}
]
}
]
}
}
它基本上说我的Http5xx不支持函数,但在本文档中它声明支持这个指标: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics
任何人都知道我做错了什么?
答案 0 :(得分:1)
你是非常过时的。使用更新的东西。该页面建议使用这个版本:2017-05-01-preview api-versión
此类型的官方api版本:2016-03-01,2015-04-01,2014-04-01