Message Routing

Emilia 20 Reputation points
2024-03-26T22:55:22.9233333+00:00

Hello, I am an undergraduate student using Azure for the first time and need some help routing messages from the IOT Hub to a container in my Storage account. I believe I filled out all of the settings properly, but am still not able to receive the JSON message in the container. Would anyone be able to give me a detailed breakdown on how to message route properly? Thank you in advance.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,112 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde 28,236 Reputation points MVP
    2024-03-26T23:51:41.24+00:00

    Hello @Emilia,

    welcome to this moderated Azure community forum.

    You are probably sending message to your IoT Hub with some SDK like this simulation:

    User's image

    Next, you need to create an Azure Storage account.

    Within the IoT Hub, add a route:

    enter image description here

    You need to give it a name, select the storage account and create a container within the storage account and select it.

    I also switched to JSON format.

    Create the endpoint.

    Next, the route must be configured:

    enter image description here

    Just enter a name. Keep the filter to 'true' so all messages are accepted.

    Create the route while skipping the enrichments.

    Once the route is created, you need to wait a little before the first file is created. It takes time for the IoT Hub to construct the underling infrastructure. This is also related to the batch frequency and chunk size window.

    It's a good sign if the endpoint is marked as healty:

    enter image description here

    Navigate to the storage account and see the first file is created after a while:

    enter image description here

    Notice the body is still base64 encoded. This is typically for the storage output, other outputs offer the actual JSON. You can easily decode it:

    enter image description here

    Check the IoT Hub metrics also regarding the storage account routing:

    enter image description here

    See also the documentation and the MS Learn module for more details.


    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.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,456 Reputation points
    2024-03-26T23:36:50.53+00:00

    Hi @Emilia Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    I wanted to check if you have looked at the Tutorial - Send device data to Azure Storage using IoT Hub message routing The article provides clear steps, including a .Net SDK sample for generating telemetry. The section Set up message routing provides steps and configurations needed to create and route data to a storage account container.

    Please ensure your Message Routing is set to Enable and for testing purposes, you can set the Routing query to true. Also, while creating the routing custom end point, ensure the Encoding format is set to JSON and not AVRO.

    Setting the query to true will route all the message data to the end point. You can refer the article IoT Hub message routing query syntax to get more information on how to formulate routing query.

    There is a slight delay between the time telemetry is generated and a blob file is written into the Storage container. This is determined by the Batch frequency parameter when creating the custom end point. Kindly expect a couple of minutes delay when you see your first file in the blob storage container.

    Hope this helps! If you still face any issue after validating the steps in the articles, please share more details on your routing query and the telemetry you are sending to the IoT Hub.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments