Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure IoT Hub - Save telemetry best practice

I am working on a IoT solution that will save weather data. I have googled for some days now on how to set up the backend. I am going to use Azure IoT Hub for handling communication, but the next step is the problem.

I want to store the telemetry to a database. This is where I get confused. Some examples says that I should use Azure BLOB storage or Azure Table storage or Azure SQL.

After some years of data collection I want to start creating reports of the data. So the storage needs to be good at working with big data.

Next problem I am stuck on is the worker that will receive the D2C and store it to database. All Azure IoT examples use a console application and some use Azure Stream analytics just to port the event to a database. What is the best practice? It needs to be able to scale and try to use best practice.

Thanks in advance!

like image 496
Krister Johansson Avatar asked Jul 29 '16 09:07

Krister Johansson


People also ask

How do I send telemetry to IoT hub?

From your Iot hub in IoT Explorer, select View devices in this hub, then select your device from the list. On the left menu for your device, select Telemetry. Confirm that Use built-in event hub is set to Yes and then select Start. View the telemetry as the device sends messages to the cloud.

Does Azure IoT hub store data?

Data collected via IoT Hub is processed in near real time by an Azure Stream Analytics job and stored in an Azure SQL database.

How do I monitor Azure IoT hub?

To open metrics explorer, go to the Azure portal and open your IoT hub, then select Metrics under Monitoring. This explorer is scoped, by default, to the platform metrics emitted by your IoT hub. For a list of the platform metrics collected for Azure IoT Hub, see Metrics in the Monitoring Azure IoT Hub data reference.

What are the three components of an azure IoT hub message?

A message enrichment has three key elements, the key name for the enrichment, the value of the enrichment key, and the endpoints that the enrichment applies to. Message enrichments are added to the IoT Hub message as application properties.


2 Answers

If you choose IoT Hub to handle communication you have a few options on how to handle the data ( make sure IoT hub is the right choice for you, if you don't need bi directional communication maybe Azure Event Hub will be a better choice, it's a lot cheaper when dealing with big data).

  • Stream analytics - Will let you output the incoming data to SQL Database, BLOB, Event Hub, Table Storage, Service Bus Queue & Topic, Document DB, Power Bi and DataLake store. In this option you won't have to manage your own worker to handle data.
  • EventProcessorHost - Here you will have to write your own implementation of getting data and storing it. This option will give you the flexibility to store the data in every storage you want but you will have to manage the hosting of the EPH. Azure Worker Rule is a good choice for hosting and scaling.
  • Storm (HD Insights) - You can use Apache storm to read data from IoT Hub, it will also give you real time computation options that is much wider from the one that Stream Analytics provides. After reading the data with Storm you also have the option to store it in every storage you want. be aware that storm on Azure is very expensive and may be an overkill for your application.

As for reporting - it really depends on your needs, I would avoid blobs/table storage for any complex reporting, those 2 are more optimized for storing a lot of data and less for making complex queries.

If you want to make you own reporting/queries you can choose Sql/DocumentDb. but make sure that if you choose NoSql solution that you will benefit from the schema less architecture.

For a Paas solution you can choose Power BI - https://powerbi.microsoft.com/en-us/blog/outputting-real-time-stream-analytics-data-to-a-power-bi-dashboard/

Disclaimer - I've answered your question on the assumption you want to use the Azure stack.

Good luck

like image 142
shachar Avatar answered Sep 21 '22 06:09

shachar


You shall be reading https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-endpoints

You shall also look at `Time Series Insights'

https://azure.microsoft.com/en-us/services/time-series-insights/

Here is my rough sketch. Time series requires token to be generated from Active Directory, but it's easy to setup.

enter image description here

As shown above,

  • Device will be sending data to IoT Hub [You can even use Device Provisioning Service here]
  • IOTHub support multiple endpoints. so one end can go to time series insights and one go to any database like CosmoDB.

    Note: Time series can store only 400 days of data, later it deletes it.

  • Regarding reports - Time series has extensive components for report and it's very fast. Also, u can access it using programming language like c#.

Important Note: Before designing any cloud architect, please work on "Sizing" factor of the data. Like, frequency of data and size. Based on that we can select the resources in azure cloud.

Please read this http://download.microsoft.com/download/A/4/D/A4DAD253-BC21-41D3-B9D9-87D2AE6F0719/Microsoft_Azure_IoT_Reference_Architecture.pdf

like image 41
kudlatiger Avatar answered Sep 19 '22 06:09

kudlatiger