简体   繁体   English

Azure IoT Hub - 使用 IoT Hub 从 Azure blob 下载文件到 IoT 设备

[英]Azure IoT Hub - Downloading file from Azure blob using IoT Hub to an IoT device

I have a use case, where I need to download the file from Azure blob location to an IoT Device which is registered with IoT Hub.我有一个用例,我需要将文件从 Azure blob 位置下载到在 IoT 中心注册的 IoT 设备。

In this case, I will be sending an instruction to IoT Device (through IoT Hub) to download the file from Azure blob location, to specific destination on the machine (where IoT Device app is running).在这种情况下,我将向 IoT 设备(通过 IoT 中心)发送一条指令,以从 Azure blob 位置下载文件到机器上的特定目标(运行 IoT 设备应用程序的位置)。

These instructions will be sent through IoT Hub using a backend (customised) application.这些指令将使用后端(自定义)应用程序通过 IoT 中心发送。

Just wanted to know whether Azure IoT Hub currently support this facility which I can use directly into the IoT Device app (by using Azure IoT API).只是想知道 Azure IoT Hub 目前是否支持这个我可以直接在 IoT Device 应用程序中使用的工具(通过使用 Azure IoT API)。

Any reference will be helpful.任何参考都会有所帮助。

Thanks,谢谢,

Avinash Deshmukh阿维纳什·德什穆赫

Yes, sure.是的,当然。 As I known, you can generate an url of an Azure Blob file with its SAS token to send it as a cloud-to-device message from IoTHub, then to receive it from IoT device and to download file via the file url with SAS token directly on the IoT device. As I known, you can generate an url of an Azure Blob file with its SAS token to send it as a cloud-to-device message from IoTHub, then to receive it from IoT device and to download file via the file url with SAS token直接在物联网设备上。

As references, you can refer to these offical documents to try to realize it.作为参考,您可以参考这些官方文档来尝试实现它。

  1. To generate a blob url with SAS token, please refer to Create an account SAS with .NET .要使用 SAS 令牌生成 blob url,请参阅Create an account SAS with .NET If you are using Java, I think it's very simple for you to write the Java one with Azure Storage SDK for Java. If you are using Java, I think it's very simple for you to write the Java one with Azure Storage SDK for Java.
  2. To send a cloud-to-device message from IoTHub, please refer to Send cloud-to-device messages with IoT Hub (Java) .要从 IoTHub Send cloud-to-device messages with IoT Hub (Java)
  3. To receive the c2d message on a device, the REST API for all languages is Device - Receive Device Bound Notification .要在设备上接收 c2d 消息,所有语言的 REST API 是Device - Receive Device Bound Notification Or you can refer to the part of sample code SendReceive.java by searching the key word D2C to know how to retrieve messages from IoT Hub.或者您可以通过搜索关键字D2C来参考示例代码SendReceive.java部分,以了解如何从IoT Hub中检索消息。
  4. If you have to get the blob url with SAS token from IoT Hub on devices, I think it's not hard for you to download a file from a public link.如果您必须从设备上的 IoT 中心获取带有 SAS 令牌的 blob url,我认为从公共链接下载文件并不难。

Hope it helps.希望能帮助到你。

Yes, you could do it by using azure cloud to device messaging.in Data parameter you can pass directly blob object url but ensure that it is belonging to the right security group.是的,您可以通过使用 azure 云到设备消息传递来做到这一点。您可以直接传递 blob object url 的数据参数,但请确保它属于正确的安全组。 You can follow the article https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d您可以关注文章https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM