gpt4 book ai didi

azure - 通过 ARM 模板使用 Http5xx 警报创建 Azure 函数失败

转载 作者:行者123 更新时间:2023-12-02 07:09:17 27 4
gpt4 key购买 nike

我正在使用 ARM 模板在 Azure 中部署资源,但我想部署同时发出警报。此案例与 Azure Function 相关。

我首先在门户中创建了 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"
}
}
]
}
}

在中间,您可以看到值为“Http5xx”的“metricName”。现在,当我将其作为 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://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics

有人知道我做错了什么吗?

最佳答案

你的 API 版本已经过时了。使用更新的东西。该页面建议此版本:2017-05-01-preview api-version

此类型的官方 API 版本:2016-03-01、2015-04-01、2014-04-01

关于azure - 通过 ARM 模板使用 Http5xx 警报创建 Azure 函数失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48329613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com