Saturday, October 14, 2017

Tapping into Azure resource group events with Event Grid

At this point in the Azure lifecycle, there are a couple of different ways you could tap into events occurring in your resource groups in Azure.  One of the newest services (still in preview) is Azure Event Grid.  The goal of this post is to use an event subscription to get access to Azure events on a target resource group in real-time.

After creating a resource group in Azure (to target), you can head on over to "Event Subscriptions" in the menu bar.

Click on the "+ Event Subscription" button, and you will follow the form to create an event subscription for a target Azure Resource Group.


A couple of notes:
  • The name has to be subscription unique, so you might want to be fairly descriptive here
  • There are 7 default event types (all the events you can do with a resource) and they are generic in nature.  Remember that an event will be created for all of them, so pick carefully not to overload any downstream systems
  • Prefix could be used to narrow this down to only the specific event types you want to target.
After you have all of this setup, you can create some events in your target resource group and watch them show up in your destination.  For my purposes, I executed an Azure Backup of a VM that I had already created.  The two events I was looking to see were the restore point creation event and the restore point deletion event.

Based on the RequestBin output, the event grid service calls out to the target url (the subscriber endpoint above) with a POST call.  The body of the POST is essentially the same as what you would see in the activity log for that event.

Of course, the endpoint could have just as easily been an Azure function or an Automation runbook.

In conclusion, the goal of this post was to tap into Azure Resource Group events via Azure Event Grid, a new service currently in preview.  We walked through a basic setup and passed our event directly to RequestBin.  Happy event tapping!

No comments:

Post a Comment