1

I'm trying to create a Webhook for Automation Runbook. So far, I've achieved the following:

  1. Create Automation account
  2. Create Runbook

Here's the template that I'm using:

"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')]"
                }
            }
        ]
    }
]

I'm not able to create a webhook. So far after searching, I couldn't find the template schema for creating the runbook also. Any help is appreciated.

Thanks in advance

juvchan
  • 6,113
  • 2
  • 22
  • 35
harryjohn
  • 656
  • 1
  • 8
  • 25

1 Answers1

1

You should not put the Webhook inside the resources of your Runbook, because a Webhook belongs to an Automation account, not a Runbook. Here is a sample:

"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')]"
                }
            }
        ]
    }
]

After testing with the template above, I get the following message:

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

As what @ElizabethCooper said below, Webhook is not supported yet in ARM Template. I have already submitted a feature request. Please vote here

Jack Zeng
  • 2,257
  • 12
  • 23
  • 1
    Automation doesn't currently support webhooks in ARM templates. It would be great if you can submit a feedback request for this feature for the Automation team to track. https://feedback.azure.com/forums/246290-automation – Elizabeth Cooper Mar 30 '16 at 17:08