1

我正在尝试为 Automation Runbook 创建一个 Webhook。到目前为止,我已经实现了以下目标:

  1. 创建自动化帐户
  2. 创建运行手册

这是我正在使用的模板:

"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 的模板架构。任何帮助表示赞赏。

提前致谢

4

1 回答 1

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。我已经提交了功能请求。请在这里投票

于 2016-03-30T07:23:03.197 回答