AZ-220 Exam QuestionsBrowse all questions from this exam

AZ-220 Exam - Question 116


You have 1,000 devices that connect to an Azure IoT hub.

You are performing a scheduled check of deployed IoT devices.

You plan to run the following command from the Azure CLI prompt. az iot hub query --hub-name hub1 --query-command "SELECT * FROM devices WHERE connectionState = 'Disconnected'"

What does the command return?

Show Answer
Correct Answer: B

The command 'az iot hub query --hub-name hub1 --query-command "SELECT * FROM devices WHERE connectionState = 'Disconnected'"' returns the device twins of the devices where the connectionState is 'Disconnected'. Device twins are JSON documents that store metadata, configurations, and conditions. The query retrieves the relevant device twin data for the disconnected devices from the device registry in the IoT Hub.

Discussion

12 comments
Sign in to comment
blackdog
Jun 5, 2020

seems like it should return the device twins of the disconnected devices

tita_tovenaar
Jun 29, 2021

correct, confirmed here (see connectionState)> https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#device-heartbeat

Yong2020
Jun 13, 2020

should be device twins.

theiotguy
Jun 18, 2020

Yes. It should be Device twins. https://docs.microsoft.com/en-us/cli/azure/ext/azure-cli-iot-ext/iot/hub?view=azure-cli-latest#ext-azure-cli-iot-ext-az-iot-hub-query-examples

valkyrieShadow
Oct 8, 2020

Review the section labeled Device and module twin queries, displaying arbitrary JSON objects, which IoT Hub enables you to query device twins and module twins. Such as; "connectionState" here is the article: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language#device-and-module-twin-queries

not_a_robot
Jul 22, 2020

Device twins

ripin_aggarwal
Aug 25, 2020

Correct option is B. The command returns the Device twin of the disconnected devices.

not_a_robot
Jul 22, 2020

Tried, returns data tiwns.

Anonymous
Nov 26, 2020

Indeed B...Tested with production data

Sudipta3009
Sep 21, 2020

It will be Device Twin only for the disconnected Device

SanjuB
Feb 26, 2021

the Device Disconnected events

Bob
Feb 5, 2021

Question says what does command return ? device twin is not something (telemetry or event or signal) which device return to hub. In my opinion A is correct.

meriadoc71
Jun 18, 2020

Not disconnected devices The IoT Hub identity registry contains a field called connectionState. Only use the connectionState field during development and debugging. IoT solutions should not query the field at run time. For example, do not query the connectionState field to check if a device is connected before you send a cloud-to-device message or an SMS.

getazusername
Nov 10, 2020

Device twin IoT Hub exposes the device twins as a document collection called devices. For example, the following query retrieves the whole set of device twins: SQL SELECT * FROM devices Source: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language