Azure Event Hubs
To setup an Azure Event Hubs pub/sub, create a component of type . See this guide on how to create and apply a pub/sub configuration. Apart from the configuration metadata fields shown below, Azure Event Hubs also supports mechanisms.
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described .
Spec metadata fields
The Azure Event Hubs pub/sub 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.
Example Configuration
Azure Event Hubs supports sending multiple messages in a single operation. To set the metadata for bulk operations, set the query parameters on the HTTP request or the gRPC metadata as documented
Create an Azure Event Hub
Follow the instructions on the to set up Azure Event Hubs.
See the documentation on how to get the Event Hubs connection string (note this is not for the Event Hubs namespace).
Create consumer groups for each subscriber
For every Dapr app that wants to subscribe to events, create an Event Hubs consumer group with the name of the Dapr app ID. For example, a Dapr app running on Kubernetes with dapr.io/app-id: "myapp"
will need an Event Hubs consumer group named myapp
.
Note: Dapr passes the name of the consumer group to the Event Hub, so this is not supplied in the metadata.
When entity management is enabled in the metadata, as long as the application has the right role and permissions to manipulate the Event Hub namespace, Dapr can automatically create the Event Hub and consumer group for you.
The Evet Hub name is the topic
field in the incoming request to publish or subscribe to, while the consumer group name is the name of the Dapr app which subscribes to a given Event Hub. For example, a Dapr app running on Kubernetes with name dapr.io/app-id: "myapp"
requires an Event Hubs consumer group named myapp
.
Subscribing to Azure IoT Hub Events
Azure IoT Hub provides an endpoint that is compatible with Event Hubs, so the Azure Event Hubs pubsub component can also be used to subscribe to Azure IoT Hub events.
The device-to-cloud events created by Azure IoT Hub devices will contain additional , and the Azure Event Hubs pubsub component for Dapr will return the following as part of the response metadata:
For example, the headers of a delivered HTTP subscription message would contain:
- Read this guide for instructions on configuring pub/sub components
Last modified February 2, 2023: Apply suggestions from code review (5f8ee9e6)