Azure Automation / SCOM: Triggering a runbook as a Recovery task using Webhooks


If you havent heard about it, the future of automation is here!

In the form of  “Azure Automation”. also known as “OMS Automation” when it is part of the Operational Management Suite (OMS).

This cloud service can control our automation, just as System center Orchestrator has done for years.

It works in a very similar way, but has been extended to support more features, for instance it supports what is known as Webhooks.

A webhook enables us to trigger a runbook using a standard HTTP call, making it easier to integrate from other tools (could for instance be used from SharePoint (See my other blog post)

but we can also use it together with SCOM as a recovery action!

This means we can easily, without any special PowerShell modules, start a runbook and send information about the event to the input of the runbook.

Inside the runbook we can utilize these inputs as mentioned in this blog post


Here is how to add it to a Monitor in SCOM:

In my little example, I am triggering a runbook to extend the drive capacity whenever a disk runs out of space. I have demoed this before using SMA and Azure Automation PowerShell Module (See this video)

Create Runbook and Webhook

1. Identify the runbook that you want to trigger as part of the Recovery Action.

NB!  In this example I want to use the Expand-VMDrive runbook to fix the problem. That runbook does not support the input from a webhook. Therefore I create another runbook called Expand-VMDriveRequest (I always just add the Request in the end of the name). to handle the inputs and call the other runbook. See the runbook content in the end of this article)


2. On the runbook blade click Webhooks


3. Click Add Webhook


4. Click Create New Webhook


5. Give it a name and set a expiration date (maximum is 10 years in the future)


6. Copy the URL! Important. Since you cannot see it once the webhook is saved

7. Configure parameters and runbook setting. In this case we can to keep the webhook data parameter empty, but I want this to run in my data center in denmark, since this is where my SCOM environment lives.


8. Click OK, then Create to save the webhook.

Now we are ready to implement this into a recovery action

Implement a webhook as a recovery action in SCOM


1. In the SCOM Console, open the properties of the monitor or rule and switch to the Diagnostic and Recovery pane


2. Click Add and select Recovery for critical health state

3. Name the action and make sure the Run recovery automatically is ticked(we want to enable it later with override)


4. Insert full path to powershell


5. Insert this parameter string (sorry about the line breaks, use the view source button to see the code)

6. Use the GUI to replace ComputerName (TEST01) and DriveLetter (C:) Values


7. The finished command parameter value looks like this (sorry about the line breaks, use the view source button to see the code):

8. Click OK to save the recovery action


9. Make sure that the recovery is disabled on all objects of the class if you do not want all machine to trigger the runbook.



10. Now set one or more overrides to enable the webhook on the specific objects that you want (in my example I only want to enable the recovery action for a specific drive on a test server).




Now trigger the alert to test the recovery action.

you can check the state changes in the health explorer to see any errors.

Your output should look like this, which includes a job ID.


Go to azure automation to check the job:


Here you can see the inputs and outputs and make sure that everything was triggered correctly:



Here is the content of the runbook that receives the information from SCOM

By |2016-02-10T15:41:56+01:00February 10th, 2016|Azure, Operations Manager (SCOM)|1 Comment

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (, 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

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (
  • SCU Europe 2014, 2015, 2016 (
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (
  • 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


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

Leave A Comment