Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 2.63 KB

iot-hub-selector-twin-get-started.md

File metadata and controls

51 lines (38 loc) · 2.63 KB

[!div class="op_single_selector"]

Introduction

Device twins are JSON documents that store device state information (metadata, configurations, and conditions). IoT Hub persists a device twin for each device that connects to it.

Use device twins to:

  • Store device metadata from your solution back end.
  • Report current state information such as available capabilities and conditions (for example, the connectivity method used) from your device app.
  • Synchronize the state of long-running workflows (such as firmware and configuration updates) between a device app and a back-end app.
  • Query your device metadata, configuration, or state.

Note

Device twins are designed for synchronization and for querying device configurations and conditions. More informations on when to use device twins can be found in Understand device twins.

Device twins are stored in an IoT hub and contain:

  • tags, device metadata accessible only by the solution back end;
  • desired properties, JSON objects modifiable by the solution back end and observable by the device app; and
  • reported properties, JSON objects modifiable by the device app and readable by the solution back end. Tags and properties cannot contain arrays, but objects can be nested.

Additionally, the solution back end can query device twins based on all the above data. Refer to Understand device twins for more information about device twins, and to the IoT Hub query language reference for querying.

Note

At this time, device twins are accessible only from devices that connect to IoT Hub using the MQTT protocol. Please refer to the MQTT support article for instructions on how to convert existing device app to use MQTT.

This tutorial shows you how to:

  • Create a back-end app that adds tags to a device twin, and a simulated device app that reports its connectivity channel as a reported property on the device twin.
  • Query devices from your back-end app using filters on the tags and properties previously created.