ARM 模板中的 Azure Application Insights 警报规则
Azure Application Insights Alert Rule in ARM Template
我正在尝试将 Application Insights 设置为附加到 Function App 和几个 Web API 的(Azure 应用服务)。
理想情况下,我们希望整个部署过程从 VSTS 构建和发布完全自动化,因此我们不必从 Azure 门户设置资源。
我已经为它创建了 ARM 模板并设法让它创建一个新的 Application Insight Azure 资源,但是它没有显示我想要的其他设置(即警报规则、计费类型和每日数据上限).
当前是否可以通过 ARM 模板设置警报规则?如果可以,请有人帮忙验证我是否有 ARM 模板:)?
{
"comments": "App Insight Alert Rule",
"type": "microsoft.insights/alertrules",
"name": "[parameters('AppInsights.AlertRuleName')]",
"apiVersion": "2014-04-01",
"location": "East US",
"tags": {
"[concat('hidden-link:/subscriptions/',subscription().subscriptionId,'/resourcegroups/',parameters('ResourceGroupName'),'/providers/microsoft.insights/components/',parameters('AppInsights.Name'))]": "Resource"
},
"properties": {
"name": "[parameters('AppInsights.AlertRuleName')]",
"description": "",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]",
"metricName": "requestFailed.count"
},
"threshold": 1,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"customEmails": "[array(parameters('AppInsights.AlertSubscriber'))]"
}
},
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]"
]
},
{
"type": "microsoft.insights/components",
"kind": "web",
"name": "[parameters('AppInsights.Name')]",
"apiVersion": "2014-04-01",
"location": "eastus",
"tags": {},
"properties": {
"ApplicationId": "[parameters('AppInsights.Name')]"
},
"dependsOn": []
},
{
"name": "[variables('billingplan')]",
"type": "microsoft.insights/components/CurrentBillingFeatures",
"location": "East US",
"apiVersion": "2015-05-01",
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]"
],
"properties": {
"CurrentBillingFeatures": "[variables('pricePlan')]",
"DataVolumeCap": {
"Cap": "[parameters('AppInsights.DailyQuota')]"
}
}
}
]
}
谢谢
哈里斯
我终于发现问题是由于我有相同的警报规则名称(不知道警报规则被视为资源并且需要具有唯一名称..)。
所以我最终将警报重命名为不同的名称,重新部署了解决方案,它最终创建了警报规则:)。
我正在尝试将 Application Insights 设置为附加到 Function App 和几个 Web API 的(Azure 应用服务)。
理想情况下,我们希望整个部署过程从 VSTS 构建和发布完全自动化,因此我们不必从 Azure 门户设置资源。
我已经为它创建了 ARM 模板并设法让它创建一个新的 Application Insight Azure 资源,但是它没有显示我想要的其他设置(即警报规则、计费类型和每日数据上限).
当前是否可以通过 ARM 模板设置警报规则?如果可以,请有人帮忙验证我是否有 ARM 模板:)?
{
"comments": "App Insight Alert Rule",
"type": "microsoft.insights/alertrules",
"name": "[parameters('AppInsights.AlertRuleName')]",
"apiVersion": "2014-04-01",
"location": "East US",
"tags": {
"[concat('hidden-link:/subscriptions/',subscription().subscriptionId,'/resourcegroups/',parameters('ResourceGroupName'),'/providers/microsoft.insights/components/',parameters('AppInsights.Name'))]": "Resource"
},
"properties": {
"name": "[parameters('AppInsights.AlertRuleName')]",
"description": "",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]",
"metricName": "requestFailed.count"
},
"threshold": 1,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"customEmails": "[array(parameters('AppInsights.AlertSubscriber'))]"
}
},
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]"
]
},
{
"type": "microsoft.insights/components",
"kind": "web",
"name": "[parameters('AppInsights.Name')]",
"apiVersion": "2014-04-01",
"location": "eastus",
"tags": {},
"properties": {
"ApplicationId": "[parameters('AppInsights.Name')]"
},
"dependsOn": []
},
{
"name": "[variables('billingplan')]",
"type": "microsoft.insights/components/CurrentBillingFeatures",
"location": "East US",
"apiVersion": "2015-05-01",
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]"
],
"properties": {
"CurrentBillingFeatures": "[variables('pricePlan')]",
"DataVolumeCap": {
"Cap": "[parameters('AppInsights.DailyQuota')]"
}
}
}
]
}
谢谢
哈里斯
我终于发现问题是由于我有相同的警报规则名称(不知道警报规则被视为资源并且需要具有唯一名称..)。
所以我最终将警报重命名为不同的名称,重新部署了解决方案,它最终创建了警报规则:)。