How to Configure Message Routing with IoT Hub – Part 1

In this article, we are going to see how to configure message routing with Azure IoT Hub. Here we will route the message to a storage account. Message routing enables us to send telemetry data from IoT Hub to custom endpoints or Event-Hub endpoints. Once the setup is done, the telemetry from IoT device to IoT Hub will automatically route to the endpoints. Please read the previous parts of the article before continuing with this one. 

How To Create Azure IoT Hub Using PowerShell 

How to Register IoT Device in Azure IoT Hub Using PowerShell 

How To Send Telemetry From An IoT Device To The Azure IoT Hub Using C# 

Routing message to a storage account: 

  •  Open your Azure portal and log in to your Azure account and choose your IoT Hub.
  •  Click Message Routing In Message Routing Pane. You can see the list of routes and custom endpoints.  

Message Routing In Message Routing Pane

  • Click +Add  button on the Routes pane. Click +Add button next to Endpoint field like below picture.
  •  Choose Blob storage from the options; add a storage endpoint which will be displayed like the image below: 

  •  Enter the name for your endpoint: here we use IoTStorageEndpoint
  •  Click Pick a container, it will take to the list of storage container that we have created in the Azure portal like below image 

  •  Choose any one of the storage account.
  • Here i choose hfazureiotjstextx  then it will display the Containers like below image. 

  •  Click +Containers button and enter the new name and access level for the container.
  • Then click Ok button . 

  •  Select the newly created container it will return to the Add a storage endpoint pane. 

  •  Use default for the rest of the fields. You can create the blob name using Blob file name format. The default is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. And this format must contain in any order. The blob name → will look like this HubflyIoTHubConnect/0/2019/02/12/18/05.  The blobs are written in Avro format.
  •  Click Create button to create the storage endpoint. It will return to the Add a route pane.
  •  Now enter the route name, Here we use IoTRoute
  •  Choose Data source as Device Telemetry Messages from the drop down list
  •  Enable Route:  Be sure this is enabled.
  •  Route Query:   Enter the route query string as level=storage.  

  •  Click SaveIt will return to the Message routing pane like below image 

That about does it. You must have learned how to configure message routing to a storage account with an IoT Hub. Should you need further assistance, kindly fill up the comment field. 

Sharing is Caring!

Leave a Reply

Your email address will not be published. Required fields are marked *