Using PowerShell, Azure Automation, and OMS – Part III
It’s been a long road, but we’re almost there! A couple of weeks ago we looked at how we can create an Azure Automation Account and add our own custom modules to the solution to be used in Azure Automation. Last week, we took a deeper dive into configuring a runbook to take in webhook data from an alert using Microsoft’s Operations Management Suite. Then we looked into the data itself to see how we can leverage it against our runbook to fix problems for us on the fly.
This week, we’re going to modify an existing function to use that webhook data directly.
Building on Webhook Data
We could actually build our logic directly into the runbook to parse the webhook data and then pass the formatted information to our function that we’ve made available in Azure. But I prefer to keep my runbooks as simple as possible and do the heavy lifting in my function. This makes the runbook look a little bit cleaner, and allows me to minimize my code management a little more. Also, Azure Automation Runbooks, as of this writing, don’t play nicely with parameter sets in them, so I might as well pass my data along to a command that does.
Originally, I had built a one-liner that allowed me to create an NSG rule on the fly to block and incoming traffic from a specific IPAddress. It was a fairly simple command. But today, we’re going to make it a little more robust, and give it the ability to use webhook data. Here’s my original code:

A couple of weeks ago, DevOps Collective (PowerShell.org’s parent non-profit organization)