Subscribe to Azure Resource Management events in Event Grid

This article explains the steps needed to subscribe to events published by Azure Resource Notifications - Resources. For detailed information about these events, see Azure Resource Notifications - Resources events.

Create Resources system topic

This section shows you how to create a system topic of type microsoft.resourcenotifications.resources.

  1. Set the account to the Azure subscription where you wish to create the system topic.

    az account set –s AZURESUBSCRIPTIONID
    
  2. Create a system topic of type microsoft.resourcenotifications.resources using the az eventgrid system-topic create command.

    az eventgrid system-topic create \
                --name SYSTEMTOPICNAME \
                --resource-group RESOURCEGROUPNAME \
                --source /subscriptions/AZURESUBSCRIPTIONID \
                --topic-type microsoft.resourcenotifications.resources \
                --location Global        
    

Subscribe to events

Create an event subscription for the above topic using the az eventgrid system-topic event-subscription create command.

The following sample command creates an event subscription for both CreatedOrUpdated and Deleted events. If you don't specify included-event-types, all the event types are included by default.

az eventgrid system-topic event-subscription create \
                --name EVENTSUBSCRIPTIONNAME \
                --resource-group RESOURCEGROUPNAME \
                --system-topic-name SYSTEMTOPICNAME \
                –-included-event-types Microsoft.ResourceNotifications.Resources.CreatedOrUpdated, Microsoft.ResourceNotifications.Resources.Deleted \
                --endpoint /subscriptions/AZURESUBSCRIPTIONID/resourceGroups/RESOURCEGROUPNAME/providers/Microsoft.EventHub/namespaces/MYEVENTHUBSNAMESPACE/eventhubs/MYEVENTHUB \
                --endpoint-type eventhub        

Delete event subscription and system topic

To delete the event subscription, use the az eventgrid system-topic event-subscription delete command. Here's an example:

az eventgrid system-topic event-subscription delete --name firstEventSubscription --resourcegroup sampletestrg --system-topic-name arnSystemTopicResources

To delete the system topic, use the az eventgrid system-topic delete command. Here's an example:

az eventgrid system-topic delete --name arnSystemTopicResources --resource-group sampletestrg

Filtering examples

Subscribe to create, update, delete notifications for virtual machines in an Azure subscription

This section shows filtering example of subscribing to create, update, and delete notifications for virtual machines in an Azure subscription.

az eventgrid system-topic event-subscription create \
	--name firstEventSubscription \
	--resource-group sampletestrg \
	--system-topic-name arnSystemTopicResources 
	--included-event-types Microsoft.ResourceNotifications.Resources.CreatedOrUpdated, Microsoft.ResourceNotifications.Resources.Deleted \
	--endpoint /subscriptions/000000000-0000-0000-0000-000000000000/resourceGroups/sampletestrg/providers/Microsoft.EventHub/namespaces/testEventHub/eventhubs/ehforsystemtopicresources \
	--endpoint-type evenhub \
    --advanced-filter data.resourceInfo.type StringEndsWith virtualMachines

Subscribe to VM create, update, and delete notifications by a particular resource group

az eventgrid system-topic event-subscription create \
	--name firstEventSubscription \
	--resource-group sampletestrg \
	--system-topic-name arnSystemTopicResources \
	--included-event-types Microsoft.ResourceNotifications.Resources.CreatedOrUpdated, Microsoft.ResourceNotifications.Resources.Deleted \
	--endpoint/subscriptions/000000000-0000-0000-0000-0000000000000/resourceGroups/sampletestrg/providers/Microsoft.EventHub/namespaces/testEventHub/eventhubs/ehforsystemtopicresources \
	--endpoint-type evenhub \
    --subject-begins-with /subscription/{Azure subscription ID}/resourceGroups/<Resource group name>/
	--advanced-filter data.resourceInfo.type StringEndsWith virtualMachines

Subscribe to VM create and update notifications by a particular location within a subscription

az eventgrid system-topic event-subscription create \
	--name firstEventSubscription \
	--resource-group sampletestrg \
	--system-topic-name arnSystemTopicResources \
	--included-event-types Microsoft.ResourceNotifications.Resources.CreatedOrUpdated \
	--endpoint/subscriptions/000000000-0000-0000-0000-0000000000000/resourceGroups/sampletestrg/providers/Microsoft.EventHub/namespaces/testEventHub/eventhubs/ehforsystemtopicresources \
	--endpoint-type evenhub \
    --subject-begins-with /subscription/{Azure subscription ID}/resourceGroups/<Resource group name>/
    --advanced-filter data.resourceInfo.location StringIn eastus 
    –-advanced-filter data.resourceInfo.type StringEndsWith virtualMachines

Contact us

If you have any questions or feedback on this feature, don't hesitate to reach us at arnsupport@microsoft.com.

To better assist you with specific feedback about a certain event, provide the following information:

For missing events:

  • System topic type name
  • Approximate timestamp in UTC when the operation was executed
  • Base resource ID for which the notification was generated
  • Navigate to your resource in Azure portal and select JSON view at the far right corner. Resource ID is the first field on the JSON view page.
  • Expected event type
  • Operation executed (for example, VM started or stopped, Storage account created etc.)
  • Description of issue encountered (for example, VM started and no Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged event generated)
  • If possible, provide the correlation ID of operation executed

For event that was delayed or has unexpected content

  • System topic type name
  • Entire contents of the notification excluding data.resourceInfo.properties
  • Description of issue encountered and impacted field values

Ensure that you aren't providing any end user identifiable information while you're sharing this data.

Next steps

For detailed information about these events, see Azure Resource Notifications - Resources events.