Skip to content
Elsie4ever edited this page Jan 4, 2023 · 18 revisions

Review these tips to maximize functionality and enjoyment out of the IoT extension

Tip#0

Append --help or -h to a command group or command for more information.

  • For command groups this will reveal the target group commands
  • For commands this will reveal information about parameters and may include usage examples.

Tip#1

Many commands require the default policy to exist on the target resource which is being manipulated. For example IoT Hub based commands commonly look for the iothubowner policy. This behavior will change in a future update.

Tip#2

For command parameters that take inline JSON, for example the az iot hub device-twin update command's --set parameter, JSON input is different between CMD, Powershell and Bash like shells.

Example update operations

The following should work with Bash:

az iot hub device-twin update -n myhub -d sensor1 --set tags='{"location":{"region":"US"}}'

az iot hub device-twin update -n myhub -d sensor1 --set tags={\"location\":{\"region\":\"US\"}}

az iot hub device-twin update -n myhub -d sensor1 --set tags="{\"location\":{\"region\":\"US\"}}"

az iot hub device-twin update -n myhub -d sensor1 --set tags="{'location':{'region':'US'}}"

The following should work with PowerShell:

az iot hub device-twin update -n myhub -d sensor1 --set tags='{\"location\":{\"region\":\"US\"}}'

az iot hub device-twin update -n myhub -d sensor1 --set tags="{'location':{'region':'US'}}"

The following should work with CMD:

az iot hub device-twin update -n myhub -d sensor1 --set tags={\"location\":{\"region\":\"US\"}}

az iot hub device-twin update -n myhub -d sensor1 --set tags="{\"location\":{\"region\":\"US\"}}"

Tip#3

In order to remove a property from Twin desired properties or tags assign the value of the target property to 'null'.

Here is how you would remove the 'storeId' property from tags.location in {"tags":{"location":{"region":"US", "storeId":12345}}}

Bash:

az iot hub device-twin update -n myhub -d sensor1 --set tags.location.storeId='null'

PowerShell:

az iot hub device-twin update -n myhub -d sensor1 --set tags.location.storeId='null'

az iot hub device-twin update -n myhub -d sensor1 --set tags.location.storeId="null"

CMD:

az iot hub device-twin update -n myhub -d sensor1 --set tags.location.storeId="null"

Tip#4

To see more data and debug information from running commands append the --debug switch to the command before executing.

Clone this wiki locally