I explored on sending data from Device to Cloud using Azure REST Apis. It is working seamlessly without any issues. I'm not finding good articles on sending Cloud-to-Device messages to Arduino board using "Azure IoT Hub REST Apis". Could some one provide suggestions on this
相关问题
- How to get the return code of a shell script in lu
- running headless chrome in an microsoft azure web
- Docker task in Azure devops won't accept "$(pw
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
相关文章
- SQL Azure Reset autoincrement
- Got ActiveRecord::AssociationTypeMismatch on model
- Multiple parameters in AngularJS $resource GET
- Global Exception Handling in Jersey & Spring?
- How to cast Azure DocumentDB Document class to my
- Can't get azure web role to run locally using
- Azure WebApp - Unable to auto-detect the runtime s
- REST search interface and the idempotency of GET
As Peter Pan said, there isn't a RESTful API for send C2D messages currently. However, you still have some other chooses.
Use Azure Function App. You can create a HTTP trigger Azure Function App to use as RESTful proxy, and run IoT Hub SDK on Azure Function App to send C2D messages.
Use AMQP over WebSockets with 443 port if you cannot use 5671 port for AMQP to connect to IoT Hub on your service side. We have developed a web based IoT Hub devtool based on Rhea, and you can reference our code.
According to the offical document Send and receive messages with IoT Hub, and after I reviewed the source codes of Azure IoT Hub for sending cloud-to-device message using different languages, there is no REST API to support on sending Cloud-to-Device messages. To send c2d message from application to Azure IoT Hub, the recommended protocol is AMQP and the simple way is using Azure IoT Hub SDK. That you can refer to the section
Communication protocol
, as below.However, if you want to receive the c2d message from Arduino, you can refer to the section
Cloud-to-device messages
and use the REST APIReceive Device Bound Notification
on Arduino.You could also send the request as the azure portal does it. All C2D from AZ Portal are sent through this Endpoint https://main.iothub.ext.azure.com/api/Service/SendMessage/ and the payload is a json that look like this:
Keep in mind that you need to add an Authorization Header with valid Bearer token. You can get this when you log in to AZ Portal.