ARM模板部署microsoft.insights/actionGroups遇AutomationRunbookServiceUriIsNotValid错误
解决ARM模板部署Action Group时的
AutomationRunbookServiceUriIsNotValid错误 我来帮你排查这个问题,你遇到的AutomationRunbookServiceUriIsNotValid错误主要有两个关键问题需要修正:
1. 错误的Automation账户资源ID引用
你的模板里automationAccountId字段用了microsoft.insights/components类型的资源ID(也就是Application Insights的资源),但这个字段要求的是Microsoft.Automation/automationAccounts类型的自动化账户资源ID。ARM无法从Application Insights资源获取到有效的Runbook服务URI,所以抛出了这个错误。
修正后的automationAccountId应该是:
"automationAccountId": "[resourceId('Microsoft.Automation/automationAccounts', parameters('AzureAutomationName'))]"
2. 变量引用格式错误
groupShortName字段你直接写了字符串"variables('ActionGroupShortName')",没有用方括号包裹,这会导致ARM把它当成字面量字符串处理,而不是解析变量值。正确的写法应该是用方括号包裹变量表达式:
"groupShortName": "[variables('ActionGroupShortName')]"
修正后的完整模板代码
{ "apiVersion": "2019-06-01", "type": "microsoft.insights/actionGroups", "location": "Global", "name": "[variables('ActionGroupName')]", "tags": { "displayName": "MyActionGroupName" }, "properties": { "groupShortName": "[variables('ActionGroupShortName')]", "enabled": true, "automationRunbookReceivers": [ { "name": "MyRunbookRecieverName", "automationAccountId": "[resourceId('Microsoft.Automation/automationAccounts', parameters('AzureAutomationName'))]", "runbookName": "MyRunbook", "webhookResourceId": "[resourceId('Microsoft.Automation/automationAccounts/webhooks', parameters('AzureAutomationName'), 'WebHookName')]", "isGlobalRunbook": false } ] } }
补充说明
虽然identifierUri不是必填项,但ARM需要通过正确的automationAccountId来自动生成对应的服务URI,所以只要确保自动化账户的资源ID正确,这个字段可以留空,ARM会自动处理。
内容的提问来源于stack exchange,提问作者Francis




