问题
I'm trying to tie microsoft.insights/alertrules
to Microsoft.Web/sites
during ARM deployment at azure.
The error is: There is no target resource for this alert CPU default-app-name-plan-ins-westeurope-default-environment
I created the resources in the template using 'automation script' of manually created resources as sample.
The alertrule:
{
"type": "microsoft.insights/alertrules",
"location": "[variables('location')]",
"apiVersion": "2016-03-01",
"name": "[concat('CPU ', variables('insightComponentName'))]",
"dependsOn": [ "[resourceId('microsoft.insights/components', variables('insightComponentName'))]" ],
"tags": "[parameters('tags')]",
"properties": {
"name": "[concat('CPU ', variables('insightComponentName'))]",
"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', variables('insightComponentName'))]",
"metricNamespace": null,
"metricName": "performanceCounter.percentage_processor_time_normalized.value"
},
"operator": "GreaterThan",
"threshold": 85,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": false,
"customEmails": [
"[parameters('alertReceiver')]"
]
}
}
},
The stack deployed with New-AzureRmResourceGroupDeployment -Verbose -ResourceGroupName rg.test.ARM -TemplateFile azuredeploy.json -TemplateParameterFile azuredeploy.parameters.json -DeploymentDebugLogLevel All
The full code is here and parameters are here
What am I doing wrong?
回答1:
I had the same error message but resolved it by adding the $type
properties to conditions
and actions
, and a tag
for the resource, following the example from this template
So it looks like:
{
"name": "[variables('responseAlertName')]",
"type": "Microsoft.Insights/alertrules",
"apiVersion": "2014-04-01",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Insights/components', variables('appInsName'))]"
],
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Insights/components', variables('appInsName')))]": "Resource"
},
"properties": {
"name": "[variables('responseAlertName')]",
"description": "response time alert",
"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.insights/components', variables('appInsName'))]",
"metricName": "request.duration"
},
"threshold": "[parameters('responseTime')]",
"windowSize": "PT5M"
},
"actions": [
{
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
]
}
}
来源:https://stackoverflow.com/questions/50056600/azure-arm-there-is-no-target-resource-for-this-alert