Subscribe to events raised by Azure Resource Notifications - Health Resources system topic (Preview)

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

Create Health Resources system topic

  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.healthresources 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.healthresources --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 the AvailabilityStatusChanged event.

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

The following sample command creates an event subscription for the ResourceAnnotated event.

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

If you don't specify included-event-types, all the event types are included by default.

To filter events from a specific resource, use the --subject-begins-with parameter. The example shows how to subscribe to AvailabilityStatusChanged events for resources in a specified resource group.

az eventgrid system-topic event-subscription create --name EVENTSUBSCRIPTIONNAME --resource-group RESOURCEGROUPNAME --system-topic-name SYSTEMTOPICNAME –included-event-types Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged --endpoint /subscriptions/AZURESUBSCRIPTIONID/resourceGroups/RESOURCEGROUPNAME/providers/Microsoft.EventHub/namespaces/MYEVENTHUBSNAMESPACE/eventhubs/MYEVENTHUB --endpoint-type eventhub --subject-begins-with /subscriptions/AZURESUBSCRIPTIONID/resourceGroups/SOURCERESOURCEGROUP/  

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 arnSystemTopicHealth

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

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

Filtering examples

Subscribe to Platform Initiated annotations belonging to Unplanned category.

You might want to filter to events that require an action. Near real-time alerts are critical in enabling quick mitigation actions. By filtering to Azure initiated and unplanned activity, you can become instantly aware of unanticipated activity across the workloads that requires immediate attention. You might want to redeploy or trigger communication to your end-users to notify the impact.

az eventgrid system-topic event-subscription create \
	--name firstEventSubscription \
	--resource-group sampletestrg \
	--system-topic-name arnSystemTopicHealth 
	--included-event-types Microsoft.ResourceNotifications.HealthResources.ResourceAnnotated \
	--endpoint /subscriptions/000000000-0000-0000-0000-000000000000/resourceGroups/sampletestrg/providers/Microsoft.EventHub/namespaces/testEventHub/eventhubs/ehforsystemtopicresources \
	--endpoint-type evenhub \
	--advanced-filter data.resourceInfo.properties.context StringEndsWith Platform Initiated \
	--advanced-filter data.resourceInfo.properties.category StringEndsWith Unplanned 

Subscribe to annotations scoped to a particular target type

Having the ability to filter to the resource types that require attention or mitigation upon impact can enable you to focus on what matters. Even within VMs, perhaps you only care when health of the parent or entire virtual machine scale set is affected versus when an instance in a virtual machine scale set is affected. This filter allows you to precisely hone in on the type of resources for which you want the near real-time alerts.

az eventgrid system-topic event-subscription create \
	--name firstEventSubscription \
	--resource-group sampletestrg \
	--system-topic-name arnSystemTopicHealth \
	--included-event-types Microsoft.ResourceNotifications.HealthResources.ResourceAnnotated \
	--endpoint/subscriptions/000000000-0000-0000-0000-0000000000000/resourceGroups/sampletestrg/providers/Microsoft.EventHub/namespaces/testEventHub/eventhubs/ehforsystemtopicresources \
	--endpoint-type evenhub \
	--advanced-filter data.resourceInfo.targetResourceType StringContains Microsoft.Compute/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 - Health Resources events.