The documentation you are viewing is for Dapr v1.3 which is an older version of Dapr. For up-to-date documentation, see the latest version.

Azure Event Hubs 绑定规范

关于 Azure Event Hubs 组件绑定的详细文档

配置

要开始 Azure 事件中心绑定,需要创建一个类型为 bindings.azure.eventhubs 的组件。 请参阅本指南,了解如何创建和应用绑定配置。

参考此实例来创建一个事件中心。

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
  namespace: <NAMESPACE>
spec:
  type: bindings.azure.eventhubs
  version: v1
  metadata:
  - name: connectionString      # Azure EventHubs connection string
    value: "Endpoint=sb://****"
  - name: consumerGroup         # EventHubs consumer group
    value: "group1"
  - name: storageAccountName    # Azure Storage Account Name
    value: "accountName"
  - name: storageAccountKey     # Azure Storage Account Key
    value: "accountKey"
  - name: storageContainerName  # Azure Storage Container Name
    value: "containerName"
  - name: partitionID           # (Optional) PartitionID to send and receive events
    value: 0

元数据字段规范

字段 必填 绑定支持 详情 示例
connectionString Y 输出 EventHubs 连接字符串。 请注意,这是 EventHubs 本身,而不是 EventHubs 名称空间。 确保使用子 EventHub 共享访问策略连接字符串 "Endpoint=sb://****"
consumerGroup Y 输出 The name of an EventHubs Consumer Group to listen on "group1"
storageAccountName Y 输出 用于在Azure 存储检查点数据的帐户的名称 "accountName"
storageAccountKey Y 输出 用于在Azure 存储检查点数据的帐户的键 "accountKey"
storageContainerName Y 输出 用于在Azure 存储检查点数据的帐户的容器名称 "contianerName"
partitionID N 输出 要发送和接收事件的分区的 ID 0

绑定支持

字段名为 ttlInSeconds

  • create

输入绑定到 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 Name 说明
iothub-connection-auth-generation-id 发送消息的设备的 connectionDeviceGenerationId See IoT Hub device identity properties.
iothub-connection-auth-method The authentication method used to authenticate the device that sent the message.
iothub-connection-device-id 发送消息的设备的 deviceId。 See IoT Hub device identity properties.
iothub-connection-module-id 发送消息的设备的 moduleId。 See IoT Hub device identity properties.
iothub-enqueuedtime The date and time in RFC3339 format that the device-to-cloud message was received by IoT Hub.

例如,HTTP Read() 响应的标头将包含:

{
  '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',
  'x-opt-sequence-number': '35',
  'x-opt-enqueued-time': '2021-07-13T22:08:09Z',
  'x-opt-offset': '21560',
  'traceparent': '00-4655608164bc48b985b42d39865f3834-ed6cf3697c86e7bd-01'
}

相关链接