Communicating with devices
Direct methods are for use when you need a direct response back, while cloud-to-device messaging is one-way communication to a device. Let us look a little deeper into these two communication methods.
Cloud-to-device messaging
Cloud-to-device messages are one-way communications to a device. They are sent to a queue that guarantees at-least-once delivery and are best used when there is intermittent connectivity of devices.
Although you can send messages to your devices in the Azure portal, you are more likely to send messages from a backend application using SDKs. The following C# code demonstrates the device code responding to a cloud-to-device message:
private static async void ReceiveMessage() { Console.WriteLine("\nReceiving messages."); while (true) { Message receivedMessage = await deviceClient...