次の方法で共有


Azure Event Grid 名前空間トピックに対するサブスクリプションのハンドラーの宛先としての Azure Event Hubs

イベント ハンドラーは、イベントの送信先となる場所です。 ハンドラーでは、イベントを処理するアクションが実行されます。 以下に、名前空間トピックでサポートされているイベント ハンドラーの一覧を示します。

Event Grid からのイベントが速すぎて、ソリューションで処理しきれない場合は、Event Hubs を使用します。 イベントがイベント ハブに格納されたら、アプリケーションでは独自のスケジュールでイベント ハブからイベントを取得して処理できます。 イベント処理をスケーリングして、受信イベントを処理することができます。

メッセージ ヘッダー

Event Hubs に送信されたイベントまたはメッセージのヘッダーで受け取るプロパティを次に示します。

プロパティ名 説明
aeg-subscription-name イベント サブスクリプションの名前。
aeg-delivery-count イベントに対して行われた試行の回数。
aeg-output-event-id システム生成イベント ID。
aeg-compatibility-mode-enabled このプロパティは、Event Grid 名前空間を介して配信する場合にのみ使用および設定できます。 現時点では、可能な値は false のみです。 これは、イベント ハンドラーが Event Grid 名前空間を介して配信されるイベントと、Event Grid カスタム トピック/システム トピック/パートナー名前空間などを区別できるようにするためのものです。
aeg-metadata-version イベントのメタデータ バージョン。 クラウド イベント スキーマの仕様バージョンを表します。

REST の例

システム割り当て ID を使用するイベント ハンドラーとして Event Hubs を使用するイベント サブスクリプション

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "SystemAssigned"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}"
            }
          }
        }
      }
    }
  }
}

ユーザー割り当て ID を使用するイベント ハンドラーとして Event Hubs を使用するイベント サブスクリプション

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{user-identity-name}"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}"
            }
          }
        }
      }
    }
  }
}

Event Hubs イベント ハンドラーで配信不能宛先が設定されたイベント サブスクリプション

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{user-identity-name}"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}"
            }
          }
        },
        "deadLetterDestinationWithResourceIdentity": {
          "identity": {
            "type": "UserAssigned",
            "userAssignedIdentities": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{user-identity-name}"
          },
          "deadLetterDestination": {
            "endpointType": "StorageBlob",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.Storage/storageAccounts/{storage-account-name}",
              "blobContainerName": "{blob-container-name}"
            }
          }
        }
      }
    }
  }
}

Event Hubs イベント ハンドラーで配信プロパティが設定されたイベント サブスクリプション

{
  "properties": {
    "deliveryConfiguration": {
      "deliveryMode": "Push",
      "push": {
        "deliveryWithResourceIdentity": {
          "identity": {
            "type": "SystemAssigned"
          },
          "destination": {
            "endpointType": "EventHub",
            "properties": {
              "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource-group}/providers/Microsoft.EventHub/namespaces/{namespace-name}/eventhubs/{eventhub-name}",
              "deliveryAttributeMappings": [
                {
                  "name": "somestaticname",
                  "type": "Static",
                  "properties": {
                    "value": "somestaticvalue"
                  }
                },
                {
                  "name": "somedynamicname",
                  "type": "Dynamic",
                  "properties": {
                    "sourceField": "subject"
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}

Event Hubs 固有の配信プロパティ

イベント サブスクリプションを使用すると、配信されたイベントに含まれる HTTP ヘッダーを設定できます。 この機能を使用すると、宛先に必要なカスタム ヘッダーを設定できます。 Azure Event Hubs に配信されるイベントにカスタム ヘッダーを設定できます。

イベントをイベント ハブ内の特定のパーティションに発行する必要がある場合は、イベント サブスクリプションに PartitionKey プロパティを設定して、対象のイベント ハブ パーティションを識別するパーティション キーを指定します。

ヘッダー名 ヘッダーの種類
PartitionKey 静的または動的

詳細については、名前空間のカスタム配信プロパティに関する記事を参照してください。

Azure portal

イベント配信モードを [プッシュ] に設定してイベント サブスクリプションを作成する場合は、イベント ハンドラーの種類として Event Hubs を選び、イベント ハブをハンドラーとして構成できます。

配信モードに [プッシュ] が選択されている [サブスクリプションの作成] ページを示すスクリーンショット。

手順について詳しくは、名前空間トピックの宛先としての Event Hubs の使用に関する記事をご覧ください。

Azure CLI

手順について詳しくは、宛先としての Event Hubs の構成に関する記事をご覧ください。

次のステップ