Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 3.58 KB

iot-hub-devguide-c2d-guidance.md

File metadata and controls

53 lines (45 loc) · 3.58 KB
title description services documentationcenter author manager editor ms.assetid ms.service ms.devlang ms.topic ms.tgt_pltfrm ms.workload ms.date ms.author
Azure IoT Hub cloud to device communications guidance | Microsoft Docs
Azure IoT Hub developer guide - guidance on when to use direct methods, device twin's desired properties, or cloud-to-device messages.
iot-hub
fsautomata
timlt
1ac90923-1edf-4134-bbd4-77fee9b68d24
iot-hub
multiple
article
na
na
11/09/2016
elioda

Cloud to device communications guidance

IoT Hub provides three options for device apps to expose functionality to a back-end app:

  • Direct methods, for communications that require immediate confirmation of their result, usually interactive control of the device, e.g. turn on a fan;
  • Twin's desired properties, for long-running commands intended to put the device into a certain desired state. For example, set the telemetry send interval to 30 minutes;
  • Cloud-to-device (C2D) messages, for one-way notifications to the device app.

Here is a detailed comparison of the various cloud-to-device communication options.

Direct methods Twin's desired properties C2D messages
Scenario Commands that require immediate confirmation, e.g. turn on a fan. Long-running commands intended to put the device into a certain desired state. For example, set the telemetry send interval to 30 minutes. One-way notifications to the device app.
Data flow Two-way. The device app can respond to the method right away. The solution back end receives the outcome contextually to the request. One-way. The device app receives a notification with the property change. One-way. The device app receives the message
Durability Disconnected devices are not contacted. Back end is notified that the device is not connected. Property values are preserved in the device twin. Device will read it at next reconnection. Property values are retrievable with the IoT Hub query language. Messages can retained by IoT Hub for up to 48 hours.
Targets Single device using deviceId, or multiple devices using jobs. Single device using deviceId, or multiple devices using jobs. Single device by deviceId.
Size Up to 8KB requests and 8KB responses. Maximum desired properties size is 8KB. Up to 256KB messages.
Frequency High. Refer to IoT Hub limits for more information. Medium. Refer to IoT Hub limits for more information. Low. Refer to IoT Hub limits for more information.
Protocol Available on MQTT and AMQP. Currently available only when using MQTT. Available on all protocol. Device has to poll when using HTTP.

Learn how to use direct methods, desired properties, and cloud-to-device messages in the following tutorials: