I have a few questions regarding best practices when using Azure IoT Edge devices.
I have a module, deployed through a deployment manifest on an edge device. This module handle messages and if needed, make a call to an API. This is working correctly. I want to send messages to that edge device and have that module handle them. I followed this tutorial and it seems to send messages without any issue.
However, I’m unsure about a few things:
My questions:
- How can I see messages sent? How can I route them to my module input?
If I have a running module listening to messages it works alright (as it’s the case in the tutorial above, but what if it’s not running, or failed due to a network issue?
I tried playing a little bit by defining routes but I don’t think they’re intended for messages sent from the cloud.
-
Should my module always be running ? I based it on this Azure docs tutorial The module is a python scripts and when it’s done, it simply exits. This is fine when setting the desired state to
stopped
and the restart policy to something other thanalways
. However, the defaults arerunning
andalways
-
If they don’t need to be always running, I thought about having a module responsible for handling messages and starting appropriate modules depending on these. Is that something common ? I’m wondering if I’m missing something
Thanks a lot for taking the time to read me!
2
Answers
For the First question
try
andcatch
in sending a message IoT device. it tracks messages delivered to a module that isn’t running or fails because of a network problem and will be held in a queue until the module is back up. Messaging delivery is guaranteed with confidence by Azure IoT Edge.It’s wise to plan your strategy to deal with sporadic module availability and network outages. Utilise Azure IoT Edge’s message retry methods, buffering capabilities, and offline support.
Sending a Message to the Module :
To send a message IoT device with
try
andexcept
:Note:
While routing is enabled the message will send to the route point.
Routing:
We can route the above endpoints. I Routed to Event Hub from the above doc and was able to capture the message of the IoT device.
In terms of wanting to see your messages from the IOT HUB side of things, try the Azure IOT Explorer. It will display the telemetry of any device, as well as have a few other bits of functionality (NOTE: Its in Preview!)
https://learn.microsoft.com/en-us/azure/iot/howto-use-iot-explorer
you need an IOT Hub connection string (not Device, not Module)
[]
For development, you can grab the IOTHubOwner policy, but be careful where that goes!
When you start the app, you will need this connection string, and when enabled, you can retrieve all the devices on the hub. when you select one, you can start subscribing to the telemetry: