Azure Automation: Using Webhooks Part 1 – Input data

One of the recently added features, Webhooks, enables you to trigger/execute a runbook from other cloud services / scripts / etc.

 

The great advantages of webhooks is:

  • Easy to trigger runbooks
  • Does not require authentication
  • uses a standard HTTP Post
  • You can submit a header and body when posting to the webhook, containing input information

This blog article will describe how to use the inputs from the HTTP post.

1.   Create a new runbook and open it in the editor

2.   Add a parameter called $Webhookdata

This parameter will receive any information from the HTTP post.

Basically it contains 3 parts:

  • WebhookName – contains the webhook name
  • RequestHeader – contains information fomr the headers, you can decide what to send. usually this would be information like, who, what and when the runbook was triggered
  • RequestBody – contains information from the request body, this is also available for custom data. usually this part is used for the actual inputs to the runbook and it is recommended to send data as JSON strings for easy handling in the code.

More info about JSON in general

3.   Read each of the parts into separate variables:

4. Convert the JSON string in the body to an object using ConvertFrom-JSON

5. Access each of the submitted values

6.   Publish the runbook

7. Add a webhook to the runbook. See the official documentation here

You’re done! Here is the complete workflow:

Next post in this series will discuss how to trigger a runbook using a web hook.

By | 2015-10-12T10:52:46+00:00 October 12th, 2015|Azure|2 Comments

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at http://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack

Training:

  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

2 Comments

  1. Robbie May 27, 2016 at 6:45 - Reply

    Hey,
    Just wanted to say thanks for your site/blog i finally managed to launch a webhook via a sharepoint workflow.

    just a simple process to prove it works.
    the process Adds permissions to a shared mailbox after inputting a mailbox name in to a sharepoint list.
    flows to azure hybrid worker / powershell
    then goes off to office 365 and adjusts permissions based on some conditions inside the script.

    thanks

Leave A Comment