az iot pnp twin

Manipulate and interact with the digital twin of an IoT Hub device.

Commands

az iot pnp twin invoke-command

Invoke a root or component level command of a digital twin device.

az iot pnp twin show

Show the digital twin of an IoT Hub device.

az iot pnp twin update

Update the read-write properties of a digital twin device via JSON patch specification.

az iot pnp twin invoke-command

Invoke a root or component level command of a digital twin device.

az iot pnp twin invoke-command --cn
                               --device-id
                               [--component-path]
                               [--hub-name]
                               [--login]
                               [--payload]
                               [--resource-group]
                               [--timeout]

Examples

Invoke root level command "reboot" which takes a payload that includes the "delay" property.

az iot pnp twin invoke-command --command-name reboot -n {iothub_name} -d {device_id} --payload '{"delay":5}'

Invoke command "getMaxMinReport" on component "thermostat1" that takes no input.

az iot pnp twin invoke-command --cn getMaxMinReport -n {iothub_name} -d {device_id} --component-path thermostat1

Required Parameters

--cn --command-name

Digital twin command name.

--device-id -d

Target Device.

Optional Parameters

--component-path

Digital twin component path. For example: thermostat1.

--hub-name -n

IoT Hub name.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority.

--payload

JSON payload input for command. Provide file path or inline JSON.

default value: {}
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--timeout --to

Maximum number of seconds to wait for device method result.

default value: 30

az iot pnp twin show

Show the digital twin of an IoT Hub device.

az iot pnp twin show --device-id
                     [--hub-name]
                     [--login]
                     [--resource-group]

Examples

Show the target device digital twin.

az iot pnp twin show -n {iothub_name} -d {device_id}

Required Parameters

--device-id -d

Target Device.

Optional Parameters

--hub-name -n

IoT Hub name.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az iot pnp twin update

Update the read-write properties of a digital twin device via JSON patch specification.

Currently operations are limited to add, replace and remove.

az iot pnp twin update --device-id
                       --json-patch
                       [--hub-name]
                       [--login]
                       [--resource-group]

Examples

Update a digital twin via JSON patch specification.

az iot pnp twin update --hub-name {iothub_name} --device-id {device_id} --json-patch '{"op":"add", "path":"/thermostat1/targetTemperature", "value": 54}'

Update a digital twin via JSON patch specification.

az iot pnp twin update -n {iothub_name} -d {device_id} --json-patch '[
  {"op":"remove", "path":"/thermostat1/targetTemperature"},
  {"op":"add", "path":"/thermostat2/targetTemperature", "value": 22}
]'

Update a digital twin property via JSON patch specification defined in a file.

az iot pnp twin update -n {iothub_name} -d {device_id} --json-patch ./my/patch/document.json

Required Parameters

--device-id -d

Target Device.

--json-patch --patch

An update specification described by JSON-patch. Operations are limited to add, replace and remove. Provide file path or inline JSON.

Optional Parameters

--hub-name -n

IoT Hub name.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.