如何创建web服务以从azure iot hub获取数据? [英] How to create a webservice to fetch data from azure iot hub?

查看:176
本文介绍了如何创建web服务以从azure iot hub获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我通过通用Windows应用程序将覆盆子pi的传感器读数发送到azure iot hub。现在我想创建一个web服务,以获取并返回azure iot hub中的数据。如果有人知道怎么做,请与我分享。

joseph。



我尝试过的:



我在azure sql中创建了一个数据库,并使用流分析连接它。但我真正需要的是一个web服务,直接连接到azure iothub端点,并从我的覆盆子pi中获取并返回来自它的json消息。

解决方案

你不应该创建webservice以访问IoT Hub。它旨在短时间保存数据。您应该将数据存储在某种存储解决方案中,然后使用webservice从存储中获取数据。这是一个快速建议,不考虑您的查询需求的复杂性。 (不同的存储解决方案根据您的查询类型执行不同的操作,您需要验证您的查询要求,以确定哪种存储解决方案最适合您。)



1。创建存储帐户和表



2.创建流分析,将输出设置为新创建的存储帐户中的表存储,并输入查询以将数据导入此表



3.启动Stream Analytics并确保其运行时没有错误消息



4。下载MS Azure存储资源管理器并验证您是否可以看到即将到来的数据



5.在AZ Storage Explorer中获取此存储帐户的SAS />


6.现在,您可以使用SAS URL参数进行身份验证,以使用OOB Web服务访问此表中的数据。以下是您的参考。



查询实体| Microsoft Docs [ ^ ]

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.

解决方案

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[^]


这篇关于如何创建web服务以从azure iot hub获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆