Muokkaa

Jaa


Event hub as an event handler for Azure Event Grid events

An event handler is the place where the event is sent. The handler takes an action to process the event. Several Azure services are automatically configured to handle events and Azure Event Hubs is one of them.

Use Event Hubs when your solution gets events from Event Grid faster than it can process the events. Once the events are in an event hub, your application can process events from the event hub at its own schedule. You can scale your event processing to handle the incoming events.

Tutorials

See the following examples:

Title Description
Quickstart: Route custom events to Azure Event Hubs with Azure CLI Sends a custom event to an event hub for processing by an application.
Resource Manager template: Create an Event Grid custom topic and send events to an event hub A Resource Manager template that creates a subscription for a custom topic. It sends events to an Azure Event Hubs.

Message headers

These are the properties you receive in the message headers:

Property name Description
aeg-subscription-name Name of the event subscription.
aeg-delivery-count Number of attempts made for the event.
aeg-event-type

Type of the event.

It can be one of the following values:

  • SubscriptionValidation
  • Notification
  • SubscriptionDeletion
aeg-metadata-version

Metadata version of the event.

For Event Grid event schema, this property represents the metadata version and for cloud event schema, it represents the spec version.

aeg-data-version

Data version of the event.

For Event Grid event schema, this property represents the data version and for cloud event schema, it doesn't apply.

aeg-output-event-id ID of the Event Grid event.

REST examples (for PUT)

Event hub

{
  "properties": 
  {
    "destination": 
    {
      "endpointType": "EventHub",
      "properties": 
      {
        "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.EventHub/namespaces/<EVENT HUBS NAMESPACE NAME>/eventhubs/<EVENT HUB NAME>"
      }
    },
    "eventDeliverySchema": "EventGridSchema"
  }
}

Event hub - delivery with managed identity

{
  "properties": {
    "deliveryWithResourceIdentity": 
    {
      "identity": 
      {
        "type": "SystemAssigned"
      },
      "destination": 
      {
        "endpointType": "EventHub",
        "properties": 
        {
          "resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.EventHub/namespaces/<EVENT HUBS NAMESPACE NAME>/eventhubs/<EVENT HUB NAME>"
        }
      }
    },
    "eventDeliverySchema": "EventGridSchema"
  }
}

Delivery properties

Event subscriptions allow you to set up HTTP headers that are included in delivered events. This capability allows you to set custom headers that the destination requires. You can set custom headers on the events that are delivered to Azure Event Hubs.

If you need to publish events to a specific partition within an event hub, set the PartitionKey property on your event subscription to specify the partition key that identifies the target event hub partition.

Header name Header type
PartitionKey Static or dynamic

For more information, see Custom delivery properties.

Next steps

See the Event handlers article for a list of supported event handlers.