az iot hub device-twin
Note
This reference is part of the azure-iot extension for the Azure CLI (version 2.59.0 or higher). 该扩展会在首次运行 az iot hub device-twin 命令时自动安装。 Learn more about extensions.
管理 IoT 设备孪生配置。
命令
名称 | 说明 | 类型 | Status |
---|---|---|---|
az iot hub device-twin list |
列出IoT 中心中的设备孪生。 |
Extension | GA |
az iot hub device-twin replace |
将设备孪生定义替换为目标 json。 |
Extension | GA |
az iot hub device-twin show |
获取设备孪生定义。 |
Extension | GA |
az iot hub device-twin update |
更新设备孪生所需的属性和标记。 |
Extension | GA |
az iot hub device-twin list
列出IoT 中心中的设备孪生。
此命令与 iot 中心查询相同,其中包含所有设备的查询“select * from devices”,“select * from devices where capabilities.iotEdge = true”for edge devices.
用于 az iot hub query
在设备上执行更强大的查询。
az iot hub device-twin list [--auth-type {key, login}]
[--edge-enabled --ee {false, true}]
[--hub-name]
[--login]
[--resource-group]
[--top]
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type={auth-type-value}
。
属性 | 值 |
---|---|
Parameter group: | Access Control Arguments |
默认值: | key |
接受的值: | key, login |
指示边缘启用的标志。
属性 | 值 |
---|---|
默认值: | False |
接受的值: | false, true |
IoT 中心名称或主机名。 如果未提供 --login,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
要返回的最大元素数。 将 -1 用于无限制。
属性 | 值 |
---|---|
默认值: | 1000 |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az iot hub device-twin replace
将设备孪生定义替换为目标 json。
直接输入 json 或使用文件路径。
az iot hub device-twin replace --device-id
--json
[--auth-type {key, login}]
[--etag]
[--hub-name]
[--login]
[--resource-group]
示例
将设备孪生替换为文件内容。
az iot hub device-twin replace -d {device_id} -n {iothub_name} -j ../mydevicetwin.json
必需参数
目标设备 ID。
用于替换现有孪生的 Json。 提供文件路径或原始 json。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type={auth-type-value}
。
属性 | 值 |
---|---|
Parameter group: | Access Control Arguments |
默认值: | key |
接受的值: | key, login |
对应于资源最后状态的 Etag 或实体标记。 如果未提供 etag,则使用值“*”。
IoT 中心名称或主机名。 如果未提供 --login,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az iot hub device-twin show
获取设备孪生定义。
az iot hub device-twin show --device-id
[--auth-type {key, login}]
[--hub-name]
[--login]
[--resource-group]
必需参数
目标设备 ID。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type={auth-type-value}
。
属性 | 值 |
---|---|
Parameter group: | Access Control Arguments |
默认值: | key |
接受的值: | key, login |
IoT 中心名称或主机名。 如果未提供 --login,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az iot hub device-twin update
更新设备孪生所需的属性和标记。
为 PATCH 行为提供 --desired 或 --tags 参数。 这两个参数都支持内联 json 或 json 内容的文件路径。 泛型更新参数(即 --set)的使用将反映 PUT 行为并已弃用。
az iot hub device-twin update --device-id
[--add]
[--auth-type {key, login}]
[--desired]
[--etag]
[--force-string]
[--hub-name]
[--login]
[--remove]
[--resource-group]
[--set]
[--tags]
示例
修补设备孪生所需的属性。
az iot hub device-twin update -n {iothub_name} -d {device_id} --desired '{"conditions":{"temperature":{"warning":70, "critical":100}}}'
修补设备孪生标记。
az iot hub device-twin update -n {iothub_name} -d {device_id} --tags '{"country": "USA"}'
使用 json 文件内容修补设备孪生标记。
az iot hub device-twin update -n {iothub_name} -d {device_id} --tags /path/to/file
从父“temperature”中删除“critical”所需属性的修补程序
az iot hub device-twin update -n {iothub_name} -d {device_id} --desired '{"condition":{"temperature":{"critical": null}}}'
必需参数
目标设备 ID。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type={auth-type-value}
。
属性 | 值 |
---|---|
Parameter group: | Access Control Arguments |
默认值: | key |
接受的值: | key, login |
孪生所需属性。
属性 | 值 |
---|---|
Parameter group: | Twin Patch Arguments |
对应于资源最后状态的 Etag 或实体标记。 如果未提供 etag,则使用值“*”。
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | False |
IoT 中心名称或主机名。 如果未提供 --login,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
从列表中删除属性或元素。 示例: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
Twin tags.
属性 | 值 |
---|---|
Parameter group: | Twin Patch Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |