az iot hub module-twin
Note
This reference is part of the azure-iot extension for the Azure CLI (version 2.59.0 or higher). The extension will automatically install the first time you run an az iot hub module-twin command. Learn more about extensions.
Manage IoT device module twin configuration.
Commands
Name | Description | Type | Status |
---|---|---|---|
az iot hub module-twin replace |
Replace a module twin definition with target json. |
Extension | GA |
az iot hub module-twin show |
Show a module twin definition. |
Extension | GA |
az iot hub module-twin update |
Update module twin desired properties and tags. |
Extension | GA |
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
[--auth-type {key, login}]
[--etag]
[--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
Target Device Id.
Json to replace existing twin with. Provide file path or raw json.
Target Module Id.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
Property | Value |
---|---|
Parameter group: | Access Control Arguments |
Default value: | key |
Accepted values: | key, login |
Etag or entity tag corresponding to the last state of the resource. If no etag is provided the value '*' is used.
IoT Hub name or hostname. Required if --login is not provided.
Property | Value |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
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. Required if --hub-name is not provided.
Property | Value |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az iot hub module-twin show
Show a module twin definition.
az iot hub module-twin show --device-id
--module-id
[--auth-type {key, login}]
[--hub-name]
[--login]
[--resource-group]
Required Parameters
Target Device Id.
Target Module Id.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
Property | Value |
---|---|
Parameter group: | Access Control Arguments |
Default value: | key |
Accepted values: | key, login |
IoT Hub name or hostname. Required if --login is not provided.
Property | Value |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
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. Required if --hub-name is not provided.
Property | Value |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az iot hub module-twin update
Update module twin desired properties and tags.
Provide --desired or --tags arguments for PATCH behavior. Both parameters support inline json or a file path to json content. 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]
[--auth-type {key, login}]
[--desired]
[--etag]
[--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 module twin tags with json file content.
az iot hub module-twin update -n {iothub_name} -d {device_id} -m {module_id} --tags /path/to/file
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
Target Device Id.
Target Module Id.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
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>
.
Property | Value |
---|---|
Parameter group: | Generic Update Arguments |
Default value: | [] |
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
Property | Value |
---|---|
Parameter group: | Access Control Arguments |
Default value: | key |
Accepted values: | key, login |
Twin desired properties.
Property | Value |
---|---|
Parameter group: | Twin Patch Arguments |
Etag or entity tag corresponding to the last state of the resource. If no etag is provided the value '*' is used.
When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
Property | Value |
---|---|
Parameter group: | Generic Update Arguments |
Default value: | False |
IoT Hub name or hostname. Required if --login is not provided.
Property | Value |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
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. Required if --hub-name is not provided.
Property | Value |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
Remove a property or an element from a list. Example: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
Property | Value |
---|---|
Parameter group: | Generic Update Arguments |
Default value: | [] |
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>
.
Property | Value |
---|---|
Parameter group: | Generic Update Arguments |
Default value: | [] |
Twin tags.
Property | Value |
---|---|
Parameter group: | Twin Patch Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |