问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/64369985/iot-hub-message-routing-with-devicelifecycleevents-source-does-not-work