丰富设备生命周期事件Azure IoT中心

问题描述

我需要丰富在事件网格中收到的设备生命周期事件[创建,删除,连接,断开连接]。 我的解决方案中的事件流如下:-

Device send registration request to IoT Hub -> Event grid triggers device life cycle event -> Event grid routes device life cycle event to Event Hub

由于我的应用程序(即仅是消费者到事件中心),这就是我将所有事件从事件网格路由到事件中心的原因。 现在,我需要丰富在事件中心收到的事件。例如,设备连接事件应如下所示:

{
  "body": [
    {
      "id": "58b1872d-1388-8043-dacc-6322ca65d2bf","topic": "SOME_TOPIC","subject": "devices/diablo-central-park-1","eventType": "Microsoft.Devices.DeviceConnected","data": {
        "deviceConnectionStateEventInfo": {
          "sequenceNumber": "SOME_SEQ_NUMBER"
        },"hubName": "IOT_HUBNAME","deviceId": "DEVICE_ID"
      },"dataVersion": "","metadataVersion": "1","eventTime": "2020-10-16T06:33:42.2418032Z"
    }
  ],"properties": {
    "aeg-output-event-id": "SOME_ID","aeg-subscription-name": "SOME_NAME,"aeg-delivery-count": "0","aeg-data-version": "","aeg-metadata-version": "1","aeg-event-type": "Notification","enrichedProperty": "enrichedValue"
  },"offset": "25769816448","sequenceNumber": 2197,"enqueuedTimeUtc": "2020-10-16T06:33:49.321Z",""systemProperties": {}
}

因此,在上述事件JSON中,我应该在属性字段中获得enrichedProperty。我已经完成了两次更改事件的消息充实,通过门户上的IoT中心刀片中的消息路由(充实消息)进行遥测。但是对于设备生命周期事件,我找不到办法。

解决方法

这应该以非常相似的方式工作。因此,您需要创建一个端点(例如存储容器),然后创建一条路由,确保在路由的数据源中选择“设备生命周期事件”。然后转到“丰富消息”选项卡,并添加所需属性的名称和值,确保选择了正确的终点。另外,请确保已启用根并且路由查询为true。现在,当您创建或删除设备时,将捕获您的事件,并且丰富的属性将显示在捕获的事件属性中。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...