How to send messages from Iot Edge Module to Storage Account through route?

Pim Klaassen 0 Reputation points
2024-12-16T13:29:02.73+00:00

I have an IoT Edge Module filtermodule which sends telemetry using send_message (docs) with IoTHubModuleClient every minute.

When I run this module, the IoT Hub message counter in the portal is incrementing. Also, I used this route in the IoT Edge Hub configuration for deployment:

"routes": {
  "filtermoduleToIoTHub": "FROM /messages/modules/filtermodule/outputs/* INTO $upstream"
}

Furthermore, I created a custom route and endpoint in IoT Hub which routes messages to a storage account (key based authentication). The route query is true and I tested the same telemetry data with the route and all tests pass in the sense that it matches the query.

I can confirm that if I use IoTHubModuleClient.create_from_connection_string(conn_string) on my local machine, the route works and data shows up in the storage account. When I use IoTHubModuleClient.create_from_edge_environment() on the IoT device within the edge environment, the route does not work (but the message counter in the portal does increment).

The same is true for monitoring events for that device in Azure IoT Explorer. When I run it locally using IoTHubModuleClient.create_from_connection_string(conn_string) I see events showing up. When I use IoTHubModuleClient.create_from_edge_environment() on the IoT device I see no events showing up. I validated that the device connection string in the iotedge config is correct.

How can I properly debug this? What am I doing wrong?

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
407 questions
Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
581 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,222 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
226 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 33,956 Reputation points MVP
    2024-12-16T16:54:43.7166667+00:00

    Hello @Pim Klaassen

    welcome to this moderated Azure community forum.

    The route on the edge seems correct regarding the output to the IoT Hub.

    The route in the IoT Hub seems pretty standard too.

    It is recommended to make use of the Azure IoT Edge module template as seen in the Visual Studio Code extension for Azure IoT Edge:

    User's image

    This provides automatically the framework for a default module that listens for incoming messages.

    As you can see, it makes use of the:

    client = IoTHubModuleClient.create_from_edge_environment()
    

    This should be sufficient.

    You could always use an extra debug module like this echo module to test the output of your Python module.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.