Share via


Event Grid での Azure リソース管理イベントのサブスクライブ (プレビュー)

この記事では、Azure リソース通知 - リソースによって公開されたイベントをサブスクライブするために必要な手順について説明します。 これらのイベントの詳細については、Azure リソース通知 - リソース イベントに関する記事を参照してください。

リソース システム トピックを作成する

このセクションでは、microsoft.resourcenotifications.resources 型のシステム トピックを作成する方法について説明します。

  1. システム トピックを作成する Azure サブスクリプションにアカウントを設定します。

    az account set –s AZURESUBSCRIPTIONID
    
  2. az eventgrid system-topic create コマンドを使用して、microsoft.resourcenotifications.resources タイプのシステム トピックを作成します。

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

イベントをサブスクライブする

az eventgrid system-topic event-subscription create コマンドを使用して、上記のトピックに対応するイベント サブスクリプションを作成します。

次のサンプル コマンドを使用すると、CreatedOrUpdated イベントと Deleted イベントの両方に対してイベント サブスクリプションが作成されます。 included-event-types を指定しない場合、すべてのイベントの種類が既定で含まれます。

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        

イベント サブスクリプションとシステム トピックを削除する

イベント サブスクリプションを削除するには、az eventgrid system-topic event-subscription delete コマンドを使用します。 次に例を示します。

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

システム トピックを削除するには、az eventgrid system-topic delete コマンドを使用します。 次に例を示します。

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

フィルター処理の例

Azure サブスクリプション内で仮想マシンの作成、更新、削除通知をサブスクライブする

このセクションでは、Azure サブスクリプション内で仮想マシンの作成、更新、削除通知のサブスクライブのフィルター処理の例を示します。

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

特定のリソース グループによる VM の作成、更新、削除通知をサブスクライブする

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

サブスクリプション内の特定の場所での VM の作成および更新通知をサブスクライブする

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

お問い合わせ

この機能について質問またはフィードバックがある場合は、ご遠慮なく arnsupport@microsoft.com までお問い合わせください。

特定のイベントについての特定のフィードバックがさらに適切に処理されるように、次の情報を提供してください。

見つからないイベントの場合:

  • システム トピックの種類の名前
  • 操作が実行された時点のおおよそのタイムスタンプ (UTC)
  • 通知が生成されたベース リソース ID
  • Azure portal でリソースに移動し、右端にある JSON ビューを選択します。 リソース ID は、JSON ビュー ページの最初のフィールドです。
  • 予期されるイベントの種類
  • 実行された操作 (起動または停止した VM、作成されたストレージ アカウントなど)
  • 発生した問題の説明 (VM は起動したが Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged イベントが生成されない、など)
  • 可能であれば、実行された操作の関連付け ID を入力してください

遅延したコンテンツや予期しないコンテンツを含むイベントの場合

  • システム トピックの種類の名前
  • 通知のすべての内容 (data.resourceInfo.properties を除く)
  • 発生した問題と影響を受けたフィールド値の説明

このデータを共有する際は、エンド ユーザーを特定できる情報を提供しないでください。

次のステップ

これらのイベントの詳細については、Azure リソース通知 - リソース イベントに関する記事を参照してください。