Trigger Automation Runbook

Trigger Automation Runbook

I’m writing this post due to a feature request I recently spotted on the Azure Logic Apps feedback forum. Given that he Azure Automation team recently introduced Webhook support, this should be very easy to complete. Here are the steps.

Trigger Automation Runbook – Steps

I’m using a manual trigger and HTTP actions only to keep this sample as simple as possible.

Note:Note: Make sure to setup the Azure Automation webhook first. The article Automation webhooks explains this in great details and even includes a Runbook sample.

  • Step 1: Start with a manual trigger followed by a HTTP Action. This HTTP Action will be responsible for calling the Azure Automation webhook. I’ve renamed the action to “CallAutomationWebhook” which can be done when switching to code view.

  • Step 2: Within the Action it’s required to provide the webhook URL (https://s1events.azure-automation.net/webhooks?token={your_token}) and set the method to POST. You can optionally provide a header and body, depending on your requirements.

  • Step 3: If you’re not intended to use the webhook return value, you can skip this step. Add a new follow-up Action, I’m using another HTTP action, and use the following syntax to get the Runbooks job is; @first(body('CallAutomationWebhook')['JobIds']).

Trigger-Automation-Runbook

That’s basically it. A very simple way to consume your existing Azure Automation assets from within Logic Apps.

The only thing strange to me, is the result of the webhook. I could not find a reason why the return value would contain a collection of job id’s. I’ve a query regarding this and the Automation team provided the following answer:

Microsoft “Right now, the job ids array will always have only one member. We built this as an array in case in the future we implement some other more complex feature(s) through webhooks that would allow for starting multiple jobs via one webhook call. But right now, you can expect that the job ids array will have only one job id in it.”

This is also the reason why it’s required to take the first result of the collection by using the @first() function.

Logic apps code sample

Additional resources

Feature request – https://feedback.azure.com/forums/287593-logic-apps/suggestions/8742013-trigger-azure-automation-runbook
Webhook documentation – https://azure.microsoft.com/en-us/documentation/articles/automation-webhooks/

Post Navigation