Azure Event Hubs binding spec

Detailed documentation on the Azure Event Hubs binding component

Component format

To setup an 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.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
spec:
  type: bindings.azure.eventhubs
  version: v1
  metadata:
    # Hub name ("topic")
    - name: eventHub
      value: "mytopic"
    - name: consumerGroup
      value: "myapp"
    # Either connectionString or eventHubNamespace is required
    # Use connectionString when *not* using Microsoft Entra ID
    - name: connectionString
      value: "Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={EventHub}"
    # Use eventHubNamespace when using Microsoft Entra ID
    - name: eventHubNamespace
      value: "namespace"
    - name: enableEntityManagement
      value: "false"
    - name: enableInOrderMessageDelivery
      value: "false"
    - name: maxConcurrentHandlers
      value: "100"
    # The following four properties are needed only if enableEntityManagement is set to true
    - name: resourceGroupName
      value: "test-rg"
    - name: subscriptionID
      value: "value of Azure subscription ID"
    - name: partitionCount
      value: "1"
    - name: messageRetentionInDays
      value: "3"
    # Checkpoint store attributes
    - name: storageAccountName
      value: "myeventhubstorage"
    - name: storageAccountKey
      value: "112233445566778899"
    - name: storageContainerName
      value: "myeventhubstoragecontainer"
    # Alternative to passing storageAccountKey
    - name: storageConnectionString
      value: "DefaultEndpointsProtocol=https;AccountName=<account>;AccountKey=<account-key>"
    # Optional metadata
    - name: getAllMessageProperties
      value: "true"
    - name: direction
      value: "input, output"

Spec metadata fields

FieldRequiredBinding supportDetailsExample
eventHubY*Input/OutputThe name of the Event Hubs hub (“topic”). Required if using Microsoft Entra ID authentication or if the connection string doesn’t contain an EntityPath valuemytopic
connectionStringY*Input/OutputConnection string for the Event Hub or the Event Hub namespace.
* Mutually exclusive with eventHubNamespace field.
* Required when not using Microsoft Entra ID Authentication
"Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={EventHub}" or "Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key}"
eventHubNamespaceY*Input/OutputThe Event Hub Namespace name.
* Mutually exclusive with connectionString field.
* Required when using Microsoft Entra ID Authentication
"namespace"
enableEntityManagementNInput/OutputBoolean value to allow management of the EventHub namespace and storage account. Default: false"true", "false"
enableInOrderMessageDeliveryNInputBoolean value that controls whether messages are processed in order within each partition. This assumes partitionKey is set when publishing to preserve ordering for related messages. Default: false"true", "false"
maxConcurrentHandlersNInputApplies only when enableInOrderMessageDelivery is false. Maximum number of outstanding handler invocations per partition. An invocation is outstanding while it runs before succeeding, and after it succeeds if an earlier invocation on the partition has not succeeded yet. The slot is freed once the invocation and every earlier one have succeeded, whether or not the checkpoint has been written. At the limit, the component stops receiving from the partition until a slot frees up. See Input binding delivery behavior. Must be greater than 0. Default: 100."100"
resourceGroupNameNInput/OutputName of the resource group the Event Hub namespace is part of. Required when entity management is enabled"test-rg"
subscriptionIDNInput/OutputAzure subscription ID value. Required when entity management is enabled"azure subscription id"
partitionCountNInput/OutputNumber of partitions for the new Event Hub namespace. Used only when entity management is enabled. Default: "1""2"
messageRetentionInDaysNInput/OutputNumber of days to retain messages for in the newly created Event Hub namespace. Used only when entity management is enabled. Default: "1""90"
consumerGroupYInputThe name of the Event Hubs Consumer Group to listen on"group1"
storageAccountNameYInputStorage account name to use for the checkpoint store."myeventhubstorage"
storageAccountKeyY*InputStorage account key for the checkpoint store account.
* When using Microsoft Entra ID, it’s possible to omit this if the service principal has access to the storage account too.
"112233445566778899"
storageConnectionStringY*InputConnection string for the checkpoint store, alternative to specifying storageAccountKey"DefaultEndpointsProtocol=https;AccountName=myeventhubstorage;AccountKey=<account-key>"
storageContainerNameYInputStorage container name for the storage account name."myeventhubstoragecontainer"
getAllMessagePropertiesNInputWhen set to true, retrieves all user/app/custom properties from the Event Hub message and forwards them in the returned event metadata. Default setting is "false"."true", "false"
directionNInput/OutputThe direction of the binding."input", "output", "input, output"

Input binding delivery behavior

When enableInOrderMessageDelivery is true, the component processes one event at a time in partition order. When false, handlers run concurrently. Both modes provide at-least-once delivery. The component retries a failed handler invocation indefinitely using the configured backoff timing, until processing succeeds or the binding shuts down.

In concurrent mode, maxConcurrentHandlers limits the number of outstanding handler invocations per partition. Each invocation handles one event. An invocation holds its slot while it runs or retries, and after it succeeds if an earlier invocation on the partition has not succeeded yet. The component frees the slot once the invocation and every earlier one have succeeded. When all slots are in use, the component stops receiving from the partition until a slot frees up. An event that keeps failing holds its slot, and so does every later invocation, so the partition stops receiving once the limit is reached.

Checkpoints advance only through contiguous successfully processed events. The component writes a checkpoint each time that range advances. For example, if events 1, 2, and 4 succeed while event 3 is still running or retrying, the checkpoint stays at event 2. After event 3 succeeds, the checkpoint advances through event 4. An existing stored checkpoint remains the restart position. If no checkpoint exists, both ordered and concurrent modes start from the earliest retained event.

Microsoft Entra ID authentication

The Azure Event Hubs pub/sub component supports authentication using all Microsoft Entra ID mechanisms. For further information and the relevant component metadata fields to provide depending on the choice of Microsoft Entra ID authentication mechanism, see the docs for authenticating to Azure.

Binding support

This component supports output binding with the following operations:

  • create: publishes a new message to Azure Event Hubs

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:

{
  'user-agent': 'fasthttp',
  'host': '127.0.0.1:3000',
  'content-type': 'application/json',
  'content-length': '120',
  'iothub-connection-device-id': 'my-test-device',
  'iothub-connection-auth-generation-id': '637618061680407492',
  'iothub-connection-auth-method': '{"scope":"module","type":"sas","issuer":"iothub","acceptingIpFilterRule":null}',
  'iothub-connection-module-id': 'my-test-module-a',
  'iothub-enqueuedtime': '2021-07-13T22:08:09Z',
  'message-id': 'my-custom-message-id',
  'x-opt-sequence-number': '35',
  'x-opt-enqueued-time': '2021-07-13T22:08:09Z',
  'x-opt-offset': '21560',
  'traceparent': '00-4655608164bc48b985b42d39865f3834-ed6cf3697c86e7bd-01'
}