Not many know and use it: Azure IoT Hub supports a REST API which can be used for sending and receiving messages. The example describes how it can be tested with postman.
How does it work?
Setup Azure
- Login to your Azure Subscripiton
- Create an IoT Hub
- Create an device and enable it
Setup Device Explorer Twin
- Download and install Azure Device Explorer (use MSI file in the download section)
- Open Device Explorer …
- and connect to you IoT hub with the Iot Hub connection string in the tab configuration
- Go to tab Management and select SAS Token
- Generate a SAS Token for the device you have created earlier
- Copy the SAS Token starting from
SharedAccessSignature=SharedAccessSignature sr=<youriothubname>.azure-devices.net%2Fdevices%2F<deviceid>&sig=....
Setup Postman
- Open Postman
- create a new Post
- New Type Post
- set URL to https://<iothubname>/devices/<deviceid>/messages/events?api-version=2018-06-30 if you want to send events from Device to cloud
- Add the following request headers
- Content-Type to application/xml
- Authorization to <paste the SAS>
- As a body add the message you want to send
Monitor activities
Option 1 Device Explorer:
- click tab Data
- select the deviceid and choose monitor
- The messages should be displayed there after sending
Option 2 Visual Studio Code:
- Connect to the IoT Hub and monitor the activities either on device or hub level