az iot hub module-twin

Manage IoT device module twin configuration.

Commands

az iot hub module-twin replace

Replace a module twin definition with target json.

az iot hub module-twin show

Show a module twin definition.

az iot hub module-twin update

Update module twin desired properties and tags.

az iot hub module-twin replace

Replace a module twin definition with target json.

Input json directly or use a file path.

az iot hub module-twin replace --device-id
                               --json
                               --module-id
                               [--hub-name]
                               [--login]
                               [--resource-group]

Examples

Replace a module twin with file contents.

az iot hub module-twin replace -d {device_id} -n {iothub_name} -m {module_name} -j ../mymodtwin.json

Required Parameters

--device-id -d

Target Device.

--json -j

Json to replace existing twin with. Provide file path or raw json.

--module-id -m

Target Module.

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 hub module-twin show

Show a module twin definition.

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

Required Parameters

--device-id -d

Target Device.

--module-id -m

Target Module.

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 hub module-twin update

Update module twin desired properties and tags.

Provide --desired or --tags arguments for PATCH behavior. Usage of generic update args (i.e. --set) will reflect PUT behavior and are deprecated.

az iot hub module-twin update --device-id
                              --module-id
                              [--add]
                              [--desired]
                              [--force-string]
                              [--hub-name]
                              [--login]
                              [--remove]
                              [--resource-group]
                              [--set]
                              [--tags]

Examples

Patch module twin desired properties.

az iot hub module-twin update -n {iothub_name} -d {device_id} -m {module_id} --desired '{"conditions":{"temperature":{"warning":70, "critical":100}}}'

Patch module twin tags.

az iot hub module-twin update -n {iothub_name} -d {device_id} -m {module_id} --tags '{"country": "USA"}'

Patch removal of 'critical' desired property from parent 'temperature'

az iot hub module-twin update -n {iothub_name} -d {device_id} -m {module_id} --desired '{"condition":{"temperature":{"critical": null}}}'

Required Parameters

--device-id -d

Target Device.

--module-id -m

Target Module.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--desired

Twin desired properties.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--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.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

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

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--tags

Twin tags.