使用 DeviceLifecycleEvents 源的 IoT 中心消息路由不起作用 [英] IoT Hub message routing with DeviceLifecycleEvents source does not work

查看:10
本文介绍了使用 DeviceLifecycleEvents 源的 IoT 中心消息路由不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在使用 IoT 中心并已配置消息路由以将 TwinChangeEvents 路由到事件中心.带有 EventHubTrigger 的 Azure 函数处理消息.这工作得很好.

现在,我想配置消息路由以将 DeviceLifecycleEvents 路由到另一个事件中心.同样,另一个带有 EventHubTrigger 的 Azure 函数应该处理这些消息.

但是,当我连接或断开设备时,不会触发该功能.当我将消息路由的数据源更改为 TwinChangeEvents 时,该函数按预期触发(当然是错误消息).也就是说,我非常有信心我的事件中心和函数的配置是正确的.

另外,我尝试在 IoT 中心配置一个事件订阅,用于事件中心的生命周期事件.我认为这个选项使用事件网格.无论如何,此配置会按预期触发该功能.仅在对生命周期事件使用消息路由时才会出现此问题.

任何人都可以为我指出为什么消息路由不起作用的解决方案吗?我是否缺少 IoT 中心的配置?

解决方案

不幸的是,事件中心不支持设备连接和断开连接事件.微软支持也证实了这一点.以下是我从他们那里得到的回复:-

<块引用>

仅为设备创建和删除事件设计的物联网设备生命周期事件.根据您希望 IoT 中心向事件中心触发以下事件的描述: 设备已创建 设备已删除 设备已连接 设备已断开 根据此要求,您应该使用事件网格创建新的事件订阅,而不是将 IoThub 消息路由与设备生命周期事件配置为数据源.请到IoT Hub,通过这个路径新建一个事件订阅:IoT Hub->Events->+Event Subscription

最后,我为所有设备生命周期事件创建了一个事件订阅,并将它们路由到我的自定义事件中心端点.我想你也可以这样做,如果你只想订阅事件中心而不是事件网格.

- 消息路由现在支持 设备连接状态事件.

I am already using an IoT Hub and have configured message routing to route TwinChangeEvents to an Event Hub. An Azure function with an EventHubTrigger processes the messages. This works perfectly fine.

Now, I wanted to configure message routing to route DeviceLifecycleEvents to another Event Hub. Again, another Azure function with an EventHubTrigger should process the messages.

However, the function is not triggered when I connect or disconnect devices. When I change the data source of the message routing to TwinChangeEvents, the function is triggered as expected (with the wrong messages of course). That said, I am pretty confident that my configuration of the Event Hub and the Function is correct.

Also, I have tried to configure an Event Subscription in the IoT Hub with for the lifecycle events to the Event Hub. I think this option uses an Event Grid. Anyways, the function gets triggered as expected with this configuration. The problem only occurs when using message routing for the lifecycle events.

Can anyone point me towards a solution why the message routing does not work? Am I missing a configuration in the IoT Hub?

解决方案

Unfortunately, Event hub doesn't support device connected and disconnected events. This has been confirmed by Microsoft support too. Below is the reply I got from them:-

IoT Device Lifecycle events designed only for device create and delete events. From the description you want your IoT Hub to trigger following events to your Event Hub: Device Created Device Deleted Device Connected Device Disconnected With this requirement you should create a new Event Subscription with Event Grid instead of configuring the IoThub message routing with Device Lifecycle Events as data source. Please go to the IoT Hub and create a new Event Subscription by this path: IoT Hub->Events->+Event Subscription

At the end of the day, I created a event subscription for all device life cycle events and routed them to my custom event hub endpoint. I think you can also do the same, If you want to only subscribe to the Event hub but not Event Grid.

EDIT:- Message routing now supports Device connection state events. Non telemetry events supported by Event hub message routing.

Finally, if a route is created with data source set to device connection state events, IoT Hub sends a message indicating whether the device was connected or disconnected.

这篇关于使用 DeviceLifecycleEvents 源的 IoT 中心消息路由不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆