Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am sending sensor readings from raspberry pi to azure iot hub through a universal windows app. Now i want to create a webservice , to fetch and return the data in azure iot hub. If anyone have any idea about how to do it, please share it with me.
joseph.

What I have tried:

I have created a db in azure sql and connected it using stream analytics. But what i actually need is a webservice to connect directly to azure iothub endpoint and fetch and return the json message coming to it from my raspberry pi.
Posted
Updated 4-Jan-17 18:33pm
Comments
Jason Gleim 5-Dec-16 10:44am    
Did you setup an event reader to get events from the hub and put them somewhere? With the IoT hub, events are placed into the hub with a timestamp. You then need to specify a reader which will copy events from the hub and do something with them... persistence to storage, analytics, etc. You can have more than one reader access the events in the hub.

Events should then expire after some amount of time. The hub itself isn't for long-term storage. Setup a simple reader to move them into a DB instance and then build your front-end against the database.
Joseph Thomas 5-Dec-16 23:57pm    
Thanks for the reply.
I didn't understand what a event reader is. Did you mean a event hub?.
As i said earlier what i did first was, using stream analytics i put the iot hub values into azure sql db. And i was able to show these values in a website using azure sql server connection string. But now what my company wants me to do is to create a webservice , which will fetch device_to_cloud message(in json) to iot hub and webservice should return that message for other applications.(They want no db in azure).

Joseph

1 solution

You should not create webservice to access the IoT Hub. It is designed to hold the data for a short period. You should store the data in some kind of storage solution and then use webservice to fetch data from the storage. Here is a quick suggestion without considering the complexity of your query need. (Different storage solutions perform differently based on your query type, and you will need to verify your query requirement to decide what storage solution works best for you.)

1. Create a Storage Account and Table

2. Create Stream Analytics, set the output to the Table Storage in the new created Storage account, and input the query to pull data into this table

3. Start the Stream Analytics and make sure it runs without error message

4. Download the MS Azure Storage Explorer and verify if you can see the data coming to the table

5. Get SAS by for this Storage account in the AZ Storage Explorer

6. Now you can use the OOB webservice to access the data in this table by using the SAS URL parameter to authenticate. Here is your reference.

Query Entities | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900