0

I have only one device connecting to Iothub and telemetry data is under 1k. In such situation, Azure Stream Analytics is too expensive.

Unlike Cosmos DB , Azure Functions has bindings of it , but SQL DB.

How can I store data from Azure Iothub into Azure SQL Database using azure function?

ps. I'm using Javascript.

FVBn
  • 97
  • 11

1 Answers1

2

Absolutely right, Stream Analytics would be overkill in this situation. My understanding of your questions is to use a Function to listen to device messages and store them in a SQL database. The steps you need to take are as follows:

  1. Create an Azure Function with a Event Hub binding to the default endpoint of IoT Hub (link)
  2. Add the SQL connection string to the application settings of the Function (link)
  3. Write JavaScript to run SQL to the database (you might need to install dependencies as the answer states. (link)
Matthijs van der Veer
  • 3,865
  • 2
  • 12
  • 22
  • Stuck on #2 . I'm not using VS and C#.. I wonder that is it available to use iotHub trigger with tedious(nodejs module) in index.js and insert data into SQL databaase ? – FVBn Jun 15 '20 at 09:25
  • I changed the link for #2 to the documentation on how to add the application setting through the Azure portal instead, hope that helps. I also added a link to an SA question that shows how sample code and how to install the dependencies correctly. – Matthijs van der Veer Jun 15 '20 at 10:04
  • After hours of testing , I finally stored telemetry data into my sql database. I also read [Working with JSON data](https://learn.microsoft.com/en-us/azure/azure-sql/database/json-features#working-with-json-data) which I could store JSON data in a table directly. Thank You Matthijs. – FVBn Jun 16 '20 at 03:21