Azure Event Hubs
To setup Azure Event Hubs pubsub create a component of type . See this guide on how to create and apply a pubsub 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 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 .
Example Configuration
Follow the instructions on setting up Azure Event Hubs. Since this implementation uses the Event Processor Host, you will also need an Azure Storage Account. Follow the instructions to manage the storage account access keys.
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 id
. For example, a Dapr app running on Kubernetes with dapr.io/app-id: "myapp"
will need an Event Hubs consumer group named .
Note: Dapr passes the name of the Consumer group to the EventHub and so this is not supplied in the metadata.
Entity Management
When entity management is enabled in configuration, as long as the application has the right role and permissions to manipulate the Event Hub namespace, creation of Event Hubs and consumer groups can be done on the fly.
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
.
Note: Dapr passes the name of the Consumer group to the EventHub and this is not supplied in the metadata.
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:
System Property Name | Description & Routing Query Keyword |
---|---|
iothub-connection-auth-generation-id | The connectionDeviceGenerationId of the device that sent the message. See IoT Hub device identity properties. |
iothub-connection-auth-method | The connectionAuthMethod used to authenticate the device that sent the message. |
iothub-connection-device-id | The deviceId of the device that sent the message. See . |
iothub-connection-module-id | The moduleId of the device that sent the message. See IoT Hub device identity properties. |
The enqueuedTime in RFC3339 format that the device-to-cloud message was received by IoT Hub. | |
message-id | The user-settable AMQP messageId. |
For example, the headers of a delivered HTTP subscription message would contain:
Related links
- Basic schema for a Dapr component
- Read for instructions on configuring pub/sub components
- Pub/Sub building block