【发布时间】:2019-04-04 12:09:17
【问题描述】:
我是 ARM 模板的新手,我正在开发一个模板以将 Web 测试和警报规则部署到应用程序洞察实例。应用洞察是使用 Terraform 创建和维护的,但 Terraform 尚不正确支持警报规则和 Web 测试。我使用的示例取自 this Github issue,但我们现在想将其分离到 Azure DevOps 管道中的一个 ARM 步骤,因为我们需要获取 webhook 警报的 URL,而我们在 Terraform 脚本中无法轻松做到这一点。
我一直在清理此示例的内容,并使用this quickstart template 作为参考点。但是,我在快速入门示例中注意到了一些在我的示例中没有的内容,而且我似乎找不到任何相关信息。
在警报规则定义属性对象中,条件对象具有odata.type,关联的dataSource 具有odata.type,如下所示:
"properties": {
"name": "[parameters('test').name]",
"description": "[parameters('test').description]",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[resourceId('microsoft.insights/webtests/', parameters('test').name)]",
"metricName": "GSMT_AvRaW"
},
"windowSize": "PT5M",
"failedLocationCount": "[parameters('test').failedLocationCount]"
},
快速入门示例几乎相同,但在 odata.type 条目之前是 $type 条目,如下所示:
"properties": {
"name": "[parameters('tests')[copyIndex(1)].name]",
"description": "[parameters('tests')[copyIndex(1)].description]",
"isEnabled": true,
"condition": {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition",
"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.insights/webtests/', parameters('tests')[copyIndex()].name)]",
"metricName": "GSMT_AvRaW"
},
"windowSize": "PT15M",
"failedLocationCount": "[parameters('tests')[copyIndex(1)].failedLocationCount]"
},
我的模板似乎仍然可以工作,但我应该包含$type 属性吗?还是它们取决于用例?我在找到这方面的任何文档方面没有取得很大成功。
【问题讨论】:
标签: azure templates azure-application-insights azure-resource-manager arm-template