Message routing enables sending telemetry data from IoT Hub to custom endpoints or Event-Hub endpoints. Once the set up is done, telemetry from IoT device to IoT Hub will automatically be routed to the endpoints. Here, we will route a message to Azure Tables.
What is Azure Stream Analytics?
Azure Stream Analytics is an event process which allows you to examine the high-level data that streams from IoT devices. Incoming data can be from IoT devices, social media feeds, applications, and more.
Please read the previous parts of the article before continuing with this one.
Set up Azure Stream Analytics
Create Stream Analytics job
- Open your Azure portal and log in to your Azure account.
- Click Create a resource -> Internet Of Things -> Stream Analytics job
The HubflyIoTJob named Stream Analytics Job is going to transfer the messages from the IoT Hub to an Azure Storage Table. Follow the below steps to configure,
- Under Job Topology, select Inputs.
- Click +Add stream input and choose IoT Hub.
- Enter the Input alias name. Here, I named it as HubInput.
- Choose Event Serialization format as JSON.
- Under Job topology, click Outputs.
- Click +Add and choose Table Storage.
- Enter the output alias name. Here, I name it as TableOutput.
- Choose Storage account where the message to be saved.
- Enter the table name. Here, I named it as HubflyIoTHubConnect.
- Enter the Partition Key and RowKey. I choose Partition key as DeviceId and Row Key as MessageId.
- The last step is to create a query. We are using a basic query, that is, “SELECT * INTO TableOutput FROM HubInput”.
- Click "Save".
- Now, go to Overview, click Start.
That’s it. I hope you have learned how to configure message routing with Azure IoT Hub using Azure Stream Analytics. Feel free to fill up the comment box below if you need any further assistance from us.