Processing device-to-cloud messaging
Cloud-to-device messages are important for any IoT device, which are mainly focused on some feedback or maintenance of these IoT devices. We send cloud-to-device messages through a service-facing endpoint (/messages/devicebound
). A device receives them through a device-specific endpoint (/devices/{deviceId}/messages/devicebound
) and takes the appropriate action on the device side based on the logic developed for the device.
These communications make the device bidirectional; some examples of bi-directional commands could be to change the configuration for a device, these fields can be time interval the device sends the data, updating some local model, size information.
How to do it...
We will be creating a simulated IoT device to send telemetry data and read that in the cloud application:
- Create a console application in the Visual Studio simulated device.
- Add the
Azure.Devices
package from NuGet. - Create an event hub client connection using the following code...