Azure Event Hubs binding spec

Detailed documentation on the Azure Event Hubs binding component

Component format

To setup Azure Event Hubs binding create a component of type bindings.azure.eventhubs. See this guide on how to create and apply a binding configuration.

See this for instructions on how to set up an Event Hub.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. spec:
  6. type: bindings.azure.eventhubs
  7. version: v1
  8. metadata:
  9. - name: connectionString # Azure EventHubs connection string
  10. value: "Endpoint=sb://****"
  11. - name: consumerGroup # EventHubs consumer group
  12. value: "group1"
  13. - name: storageAccountName # Azure Storage Account Name
  14. value: "accountName"
  15. - name: storageAccountKey # Azure Storage Account Key
  16. value: "accountKey"
  17. - name: storageContainerName # Azure Storage Container Name
  18. value: "containerName"
  19. - name: partitionID # (Optional) PartitionID to send and receive events
  20. value: 0

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Spec metadata fields

FieldRequiredBinding supportDetailsExample
connectionStringYOutputThe EventHubs connection string. Note that this is the EventHub itself and not the EventHubs namespace. Make sure to use the child EventHub shared access policy connection string“Endpoint=sb://**
consumerGroupYOutputThe name of an EventHubs Consumer Group to listen on“group1”
storageAccountNameYOutputThe name of the account of the Azure Storage account to persist checkpoints data on“accountName”
storageAccountKeyYOutputThe account key for the Azure Storage account to persist checkpoints data on. Not required if using AAD authentication.“accountKey”
storageContainerNameYOutputThe name of the container in the Azure Storage account to persist checkpoints data on“containerName”
partitionIDNOutputID of the partition to send and receive events0
eventHubNOutputThe name of the EventHubs hub. Required if using AAD authentication.eventHubsNamespace-hubName
eventHubNamespaceNOutputThe name of the EventHubs namespace. Required if using AAD authentication.eventHubsNamespace

Azure Active Directory (AAD) authentication

The Azure Event Hubs pubsub component supports authentication using all Azure Active Directory mechanisms. For further information and the relevant component metadata fields to provide depending on the choice of AAD authentication mechanism, see the docs for authenticating to Azure.

Binding support

This component supports output binding with the following operations:

  • create

Input Binding to Azure IoT Hub Events

Azure IoT Hub provides an endpoint that is compatible with Event Hubs, so Dapr apps can create input bindings to read Azure IoT Hub events using the Event Hubs bindings component.

The device-to-cloud events created by Azure IoT Hub devices will contain additional IoT Hub System Properties, and the Azure Event Hubs binding for Dapr will return the following as part of the response metadata:

System Property NameDescription & Routing Query Keyword
iothub-connection-auth-generation-idThe connectionDeviceGenerationId of the device that sent the message. See IoT Hub device identity properties.
iothub-connection-auth-methodThe connectionAuthMethod used to authenticate the device that sent the message.
iothub-connection-device-idThe deviceId of the device that sent the message. See IoT Hub device identity properties.
iothub-connection-module-idThe moduleId of the device that sent the message. See IoT Hub device identity properties.
iothub-enqueuedtimeThe enqueuedTime in RFC3339 format that the device-to-cloud message was received by IoT Hub.
message-idThe user-settable AMQP messageId.

For example, the headers of a HTTP Read() response would contain:

  1. {
  2. 'user-agent': 'fasthttp',
  3. 'host': '127.0.0.1:3000',
  4. 'content-type': 'application/json',
  5. 'content-length': '120',
  6. 'iothub-connection-device-id': 'my-test-device',
  7. 'iothub-connection-auth-generation-id': '637618061680407492',
  8. 'iothub-connection-auth-method': '{"scope":"module","type":"sas","issuer":"iothub","acceptingIpFilterRule":null}',
  9. 'iothub-connection-module-id': 'my-test-module-a',
  10. 'iothub-enqueuedtime': '2021-07-13T22:08:09Z',
  11. 'message-id': 'my-custom-message-id',
  12. 'x-opt-sequence-number': '35',
  13. 'x-opt-enqueued-time': '2021-07-13T22:08:09Z',
  14. 'x-opt-offset': '21560',
  15. 'traceparent': '00-4655608164bc48b985b42d39865f3834-ed6cf3697c86e7bd-01'
  16. }

Last modified July 27, 2022: Remove namespace element from component examples (#2647) (ff9de5c8)