az iot device c2d-message
Note
This reference is part of the azure-iot extension for the Azure CLI (version 2.59.0 or higher). 该扩展将在首次运行 az iot device c2d-message 命令时自动安装。 Learn more about extensions.
云到设备的消息传送命令。
命令
名称 | 说明 | 类型 | Status |
---|---|---|---|
az iot device c2d-message abandon |
放弃云到设备的消息。 |
Extension | GA |
az iot device c2d-message complete |
完成云到设备的消息。 |
Extension | GA |
az iot device c2d-message purge |
清除目标设备的云到设备消息队列。 |
Extension | GA |
az iot device c2d-message receive |
接收云到设备的消息。 |
Extension | GA |
az iot device c2d-message reject |
拒绝或终止云到设备的消息。 |
Extension | GA |
az iot device c2d-message send |
发送云到设备的消息。 |
Extension | GA |
az iot device c2d-message abandon
放弃云到设备的消息。
az iot device c2d-message abandon --device-id
[--etag]
[--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.
对应于资源最后状态的 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 device c2d-message complete
完成云到设备的消息。
az iot device c2d-message complete --device-id
[--etag]
[--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.
对应于资源最后状态的 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 device c2d-message purge
清除目标设备的云到设备消息队列。
az iot device c2d-message purge --device-id
[--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.
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 device c2d-message receive
接收云到设备的消息。
仅当接收的消息正文的内容编码设置为“utf-8”、“utf-16”或“utf-32”时,才会解码接收的消息正文。 当内容编码未设置为上述之一时,消息有效负载将显示为 {{不可解码的有效负载}},或者即使内容编码设置为上述内容编码之一,也不会解码。
注意:仅接受一个消息确认参数 [--complete, --reject, --abandon]。
az iot device c2d-message receive --device-id
[--abandon {false, true}]
[--complete {false, true}]
[--hub-name]
[--lock-timeout --lt]
[--login]
[--reject {false, true}]
[--resource-group]
示例
Basic usage
az iot device c2d-message receive -d {device_id} -n {hub_name} -g {resource_group}
接收消息,并为该消息设置 30 秒的锁定超时
az iot device c2d-message receive -d {device_id} -n {hub_name} -g {resource_group} --lt {30}
接收消息并在收到消息后将其确认为“完成”
az iot device c2d-message receive -d {device_id} -n {hub_name} -g {resource_group} --complete
接收消息并在收到消息后拒绝它
az iot device c2d-message receive -d {device_id} -n {hub_name} -g {resource_group} --reject
必需参数
目标设备 ID。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
在收到后放弃云到设备的消息。
属性 | 值 |
---|---|
Parameter group: | Message Ack Arguments |
默认值: | False |
接受的值: | false, true |
在收到后完成云到设备的消息。
属性 | 值 |
---|---|
Parameter group: | Message Ack Arguments |
默认值: | False |
接受的值: | false, true |
IoT 中心名称或主机名。 如果未提供 --login,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
指定消息对其他接收调用不可见的时间。
属性 | 值 |
---|---|
默认值: | 60 |
此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
收到后拒绝云到设备的消息。
属性 | 值 |
---|---|
Parameter group: | Message Ack Arguments |
默认值: | False |
接受的值: | false, true |
资源组的名称。 可以使用 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 device c2d-message reject
拒绝或终止云到设备的消息。
az iot device c2d-message reject --device-id
[--etag]
[--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.
对应于资源最后状态的 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 device c2d-message send
发送云到设备的消息。
此命令依赖于并可能在首次执行时安装依赖的 Cython 包(uamqp)。 https://github.com/Azure/azure-uamqp-python
注意:内容编码默认为 utf-8。 当内容编码属性为 utf-8、utf-16 或 utf-32 时,此命令将发送带有编码操作的消息正文。 如果内容编码值不是其中之一,则仍会发送该属性,不执行任何编码操作。
发送二进制消息正文时,必须从文件(通过 --data-file-path
)提供内容,并且内容类型必须设置为 application/octet-stream
。
az iot device c2d-message send --device-id
[--ack {full, negative, positive}]
[--auth-type {key, login}]
[--ce --content-encoding]
[--cid --correlation-id]
[--content-type --ct]
[--da --data]
[--data-file-path --dfp]
[--expiry --expiry-time-utc]
[--hub-name]
[--login]
[--message-id --mid]
[--properties --props]
[--repair {false, true}]
[--resource-group]
[--uid --user-id]
[--wait {false, true}]
[--yes {false, true}]
示例
默认消息正文的基本用法
az iot device c2d-message send -d {device_id} -n {iothub_name}
使用自定义数据和属性发送云到设备的消息。
az iot device c2d-message send -d {device_id} -n {iothub_name} --data 'Hello World' --props 'key0=value0;key1=value1'
发送 C2D 消息并等待设备确认
az iot device c2d-message send -d {device_id} -n {iothub_name} --ack full --wait
从文件中以二进制格式发送 C2D 消息。
az iot device c2d-message send -d {device_id} -n {iothub_name} --data-file-path {file_path} --content-type 'application/octet-stream'
从文件发送 JSON 格式的 C2D 消息。
az iot device c2d-message send -d {device_id} -n {iothub_name} --data-file-path {file_path} --content-type 'application/json'
必需参数
目标设备 ID。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
请求传送有关该邮件的最终状态的每封邮件反馈。 ack 值的说明如下所示。 积极:如果 c2d 消息达到“已完成”状态,IoT 中心将生成反馈消息。 负:如果 c2d 消息达到死信状态,IoT 中心将生成反馈消息。 完整:IoT 中心在任一情况下都生成反馈消息。 默认情况下,不会请求任何确认。
属性 | 值 |
---|---|
接受的值: | full, negative, positive |
指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type={auth-type-value}
。
属性 | 值 |
---|---|
Parameter group: | Access Control Arguments |
默认值: | key |
接受的值: | key, login |
C2D 消息正文的编码。
属性 | 值 |
---|---|
默认值: | utf-8 |
与 C2D 消息关联的关联 ID。
C2D 消息正文的内容类型。
Message body. 提供文本或原始 json。
属性 | 值 |
---|---|
默认值: | Ping from Az CLI IoT Extension |
提供消息正文有效负载的文件路径。 请注意,当需要以二进制格式发送有效负载时,请将内容类型设置为 application/octet-stream。
单位是自 unix 纪元以来的毫秒数。 如果未指示任何时间,则使用默认的 IoT 中心 C2D 消息 TTL。
IoT 中心名称或主机名。 如果未提供 --login,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。
属性 | 值 |
---|---|
Parameter group: | IoT Hub Identifier Arguments |
C2D 消息 ID。如果未提供任何消息 ID,将生成 UUID。
键值对中的消息属性包采用以下格式:a=b;c=d。
重新安装与扩展版本兼容的 uamqp 依赖项。 Default: false.
属性 | 值 |
---|---|
默认值: | False |
接受的值: | false, true |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
C2D 消息,用户 ID 属性。
如果设置 c2d 发送作将阻止,直到收到设备反馈。
属性 | 值 |
---|---|
默认值: | False |
接受的值: | false, true |
跳过用户提示。 指示接受操作。 主要用于自动化方案。 Default: false.
属性 | 值 |
---|---|
默认值: | False |
接受的值: | false, true |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | 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 |