Create an Azure Monitor action group with Azure PowerShell

December 27, 2018 at 12:40 pm in action groups, automation, Azure, Azure Monitor, Azure PowerShell, beemug by Wim Matthyssen

Azure Monitor, Microsoft’s built-in monitoring service, allows you to monitor and gain more visibility into the state of your resources from a single place in the Azure portal, to help you quickly find and fix problems.

To notify users that an alert has been triggered, Azure Monitor (and also Service Health alerts) uses action groups. This feature allows an owner of an Azure subscription to group a collection of actions to take when an alert is triggered. Owners can create an action group with functions such as sending an email or SMS, as well as calling a webhook and re-use it across multiple alerts. Action groups can be created through the Azure portal, but to automate the process you can also use Azure PowerShell.

In the below example a new action group, called email-ag, is created. To use the script, copy it and adjust it for your own purpose. Save it as .ps1.

clip_image002

You can check all existing action groups in your subscription, by running the below cmdlet. In my example the previously created action group email-ag is shown.

clip_image004

Like earlier said, you can also Add, validate or manage action groups through the Azure portal by opening Monitor, selecting Alerts and selecting Manage action groups. For more information you can check out the documentation page.

clip_image006

clip_image008

Hope the script comes in handy!

Wim Matthyssen (@wmatthyssen)

Share on LinkedInTweet about this on TwitterShare on Google+Share on Facebook