Share via


訂閱 Azure 資源通知 - 健康情況資源所引發的事件系統主題 (預覽)

本文說明訂閱 Azure 資源通知 - 健康情況資源所發佈事件所需的步驟。 如需關於這些事件的詳細資訊,請參閱 Azure 資源通知 - 健康情況資源事件

建立健康情況資源系統主題

  1. 將帳戶設定為您要在其中建立系統主題的 Azure 訂用帳戶。

    az account set –s AZURESUBSCRIPTIONID
    
  2. 使用 az eventgrid system-topic create 命令建立 microsoft.resourcenotifications.healthresources 類型的系統主題。

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

訂閱事件

使用 az eventgrid system-topic event-subscription create 命令來建立上述主題的事件訂閱。

下列範例命令會為 AvailabilityStatusChanged 事件建立事件訂閱。

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        

下列範例命令會為 ResourceAnnotated 事件建立事件訂閱。

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        

如果您未指定 included-event-types,則預設會包含所有事件類型。

若要從特定資源篩選事件,請使用 --subject-begins-with 參數。 此範例示範如何針對指定資源群組中的資源訂閱 AvailabilityStatusChanged 事件。

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/  

刪除事件訂閱與系統主題

若要刪除事件訂閱,請使用 az eventgrid system-topic event-subscription delete 命令。 以下是範例:

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

若要刪除系統主題,請使用 az eventgrid system-topic delete 命令。 以下是範例:

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

篩選範例

訂閱屬於 [非計劃性] 類別的 [平台起始] 註釋。

您可能要篩選為需要動作的事件。 近乎即時的警示對於啟用快速風險降低動作至關重要。 您可以篩選至 Azure 起始和非計劃性活動,您可以了解需要立即注意工作負載的未預期活動。 您可能需要重新部署或觸發與終端使用者的通訊,以通知影響。

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 

訂閱範圍限定在特定目標類型的註釋

能夠篩選到在受影響時需要注意或風險降低的資源類型,可讓您專注於重要事項。 即使在 VM 內,相對於在虛擬機擴展集的一個執行個體受到影響時,您也只會在父代或整個虛擬機擴展集的健康情況受到影響時才需要注意。 此篩選可讓您精確磨練您需要近乎即時警示的資源類型。

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

與我們連絡

如果您對這項功能有任何疑問或意見反應,請立即與我們連絡:arnsupport@microsoft.com

為了更妥善地協助您處理特定事件的特定意見反應,請提供下列資訊:

針對遺失的事件:

  • 系統主題類型名稱
  • 執行作業時,UTC 的近似時間戳記
  • 產生通知的基底資源識別碼
  • 在 Azure 入口網站中瀏覽至您的資源,然後選取最右側的 JSON 檢視。 資源識別碼是 JSON 檢視頁面上的第一個欄位。
  • 預期的事件類型
  • 執行的作業 (例如 VM 已啟動或停止、已建立記憶體帳戶等)
  • 發生問題的描述 (例如,VM 已啟動,且未產生 Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged 事件)
  • 可能的話,請提供所執行作業的相互關聯識別碼

針對延遲或有非預期內容的事件

  • 系統主題類型名稱
  • 通知的整個內容 (排除 data.resourceInfo.properties)
  • 所遇到問題的描述和受影響欄位的值

請確定您在共用此資料時,未提供任何終端使用者可識別的資訊。

下一步

如需關於這些事件的詳細資訊,請參閱 Azure 資源通知 - 健康情況資源事件