我正在尝试创建一个Webhook for Automation Runbook。到目前为止,我已经实现了以下目标:
这是我使用的模板:
"resources": [
{
"name": "[parameters('accountName')]",
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "2015-10-31",
"location": "[parameters('location')]",
"dependsOn": [ ],
"tags": { },
"properties": {
"sku": {
"name": "[parameters('sku')]"
}
},
"resources": [
{
"name": "[variables('runbookName')]",
"type": "runbooks",
"apiVersion": "2015-10-31",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"tags": { },
"properties": {
"runbookType": "Script",
"logProgress": "false",
"logVerbose": "false",
"publishContentLink": {
"uri": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1",
"version": "1.0.0.0"
},
"webhook": {
"name": "test"
}
}
,"resources": [
{
"apiVersion": "2015-10-31",
"type": "webhooks",
"name": "testwebhook",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/', variables('runbookName'))]"
]
}
]
},
{
"name": "[parameters('credentialName')]",
"type": "credentials",
"apiVersion": "2015-10-31",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"tags": { },
"properties": {
"userName": "[parameters('userName')]",
"password": "[parameters('password')]"
}
}
]
}
]
我无法创建webhook。搜索后到目前为止,我还无法找到用于创建Runbook的模板架构。任何帮助表示赞赏。
提前致谢
答案 0 :(得分:1)
您不应将Webhook放在Runbook的资源中,因为Webhook属于自动化帐户,而不属于Runbook。这是一个示例:
"resources": [
{
"name": "[parameters('accountName')]",
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "2015-10-31",
"location": "[parameters('location')]",
"dependsOn": [ ],
"tags": { },
"properties": {
"sku": {
"name": "[parameters('sku')]"
}
},
"resources": [
{
"name": "[variables('runbookName')]",
"type": "runbooks",
"apiVersion": "2015-10-31",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"tags": { },
"properties": {
"runbookType": "Script",
"logProgress": "false",
"logVerbose": "false",
"publishContentLink": {
"uri": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1",
"version": "1.0.0.0"
},
"webhook": {
"name": "test"
}
}
,"resources": [
]
},
{
"apiVersion": "2015-10-31",
"type": "webhooks",
"name": "testwebhook",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/', variables('runbookName'))]"
],
"properties": {
"isEnabled": true,
"runbook": {
"name": "[variables('runbookName')]"
}
}
},
{
"name": "[parameters('credentialName')]",
"type": "credentials",
"apiVersion": "2015-10-31",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"tags": { },
"properties": {
"userName": "[parameters('userName')]",
"password": "[parameters('password')]"
}
}
]
}
]
使用上面的模板测试后,我收到以下消息:
New-AzureRmResourceGroupDeployment : 9:35:31 AM - Resource Microsoft.Automation/automationAccounts/webhooks 'automationARMtest/testwebhook' failed with message '{"Message":"Invalid Uri"}'
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -name automationARMtest -ResourceG ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand
正如@ElizabethCooper在下面所述,ARM模板中尚不支持Webhook。我已经提交了功能请求。请投票here