你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az iot edge deployment

注意

此参考是 Azure CLI(版本 2.37.0 或更高版本)的 azure-iot 扩展的一部分。 该扩展将在首次运行 az iot edge deployment 命令时自动安装。 详细了解扩展。

大规模管理 IoT Edge 部署。

命令

名称 说明 类型 状态
az iot edge deployment create

在目标IoT 中心中创建 IoT Edge 部署。

扩展 GA
az iot edge deployment delete

删除 IoT Edge 部署。

扩展 GA
az iot edge deployment list

列出IoT 中心中的 IoT Edge 部署。

扩展 GA
az iot edge deployment show

获取 IoT Edge 部署的详细信息。

扩展 GA
az iot edge deployment show-metric

评估 IoT Edge 部署中定义的目标系统指标。

扩展 GA
az iot edge deployment update

更新 IoT Edge 部署的指定属性。

扩展 GA

az iot edge deployment create

在目标IoT 中心中创建 IoT Edge 部署。

部署内容为 json,格式为 {“modulesContent”:{...}} 或 {“content”:{“modulesContent”:{...}}}。

默认情况下,系统模块的属性$edgeAgent和$edgeHub根据随 IoT 扩展一起安装的架构进行验证。 此验证适用于基本部署。 如果相应的架构不可用或未检测到基本部署格式,将跳过此步骤。 可以使用 --no-validation 开关禁用架构验证。

如果模块定义了 properties.desired.*,则边缘部署被归类为分层部署。 任何以分层部署为目标的边缘设备,首先需要应用基础部署。

面向设备的任何分层部署的优先级必须高于该设备的基本部署。

注意:如果在分层部署中设置了模块孪生的 properties.desired 字段,properties.desired 将在任何较低优先级的部署中覆盖该模块的所需属性。

az iot edge deployment create --content
                              --deployment-id
                              [--auth-type {key, login}]
                              [--cl]
                              [--cmq]
                              [--hub-name]
                              [--lab]
                              [--layered {false, true}]
                              [--login]
                              [--metrics]
                              [--no-validation {false, true}]
                              [--pri]
                              [--resource-group]
                              [--target-condition]

示例

使用标签(bash 语法示例)创建部署,该示例适用于“building 9”中的设备,环境为“test”。

az iot edge deployment create -d {deployment_name} -n {iothub_name} --content ./modules_content.json --labels '{"key0":"value0", "key1":"value1"}' --target-condition "tags.building=9 and tags.environment='test'" --priority 3

使用标签(powershell 语法示例)创建一个部署,该示例适用于使用环境“dev”标记的设备。

az iot edge deployment create -d {deployment_name} -n {iothub_name} --content ./modules_content.json --labels "{'key':'value'}" --target-condition "tags.environment='dev'"

创建适用于使用环境“dev”标记的设备的分层部署。 内联定义的用户指标和模块内容(powershell 语法示例)。 请注意,这是分层部署格式,因为 properties.desired.* 已定义。

az iot edge deployment create -d {deployment_name} -n {iothub_name} --content "{'modulesContent':{'`$edgeAgent':{
  'properties.desired.modules.mymodule0':{ }},'`$edgeHub':{'properties.desired.routes.myroute0':'FROM /messages/* INTO `$upstream'}}}"
--target-condition "tags.environment='dev'" --priority 10 --metrics "{'queries':{'mymetrik':'SELECT deviceId from devices where properties.reported.lastDesiredStatus.code = 200'}}"

创建适用于“building 9”和环境“test”中的设备的分层部署。 内联定义的用户指标和模块内容(bash 语法示例)。 请注意,这是分层部署格式,因为 properties.desired.* 已定义。

az iot edge deployment create -d {deployment_name} -n {iothub_name} --content '{"modulesContent":{"$edgeAgent":{"properties.desired.modules.mymodule0":{ }},"$edgeHub":{"properties.desired.routes.myroute0":"FROM /messages/* INTO $upstream"}}}' --target-condition "tags.building=9 and tags.environment='test'" --metrics '{"queries":{"mymetrik":"SELECT deviceId from devices where properties.reported.lastDesiredStatus.code = 200"}}'

创建适用于“生成 9”和环境“test”中的设备的部署。 从文件定义的用户指标和模块内容。

az iot edge deployment create -d {deployment_name} -n {iothub_name} --content ./modules_content.json --target-condition "tags.building=9 and tags.environment='test'" --metrics ./metrics_content.json

创建一个部署,其定义来自具有不区分 shell 的标签和指标输入的文件。

az iot edge deployment create -d {deployment_name} -n {iothub_name} --content ./modules_content.json --target-condition "tags.building=9 and tags.environment='test'" --custom-labels key0=value0 key1=value1 --custom-metric-queries mymetric1="select deviceId from devices where tags.location='US'" mymetric2="select *"

必需参数

--content -k

IoT Edge 部署内容。 提供文件路径或原始 json。

--deployment-id -d

目标部署名称。 允许小写和以下特殊字符:[-+%_*!']。

可选参数

--auth-type

指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type=<auth-type-value>

接受的值: key, login
默认值: key
--cl --custom-labels

--labels 的替代输入样式(空格分隔键=值对),并打算在未来替换它。 格式示例:key1=value1 key2=“this is my value”。

--cmq --custom-metric-queries

用于 --metrics 的替代输入样式(空格分隔键=值对),并打算在未来替换它。 格式示例:metric1=“select deviceId from devices where tags.location='US'” metric2=“select *”。

--hub-name -n

IoT 中心名称或主机名。 如果未提供 --login,则为必需。

--lab --labels

要应用于目标部署的标签映射。 使用以下格式:“{”key0“:”value0“,”key1“:”value1“}”。 建议使用 --custom-labels 而不是 --labels。

--layered

分层部署允许在$edgeAgent、$edgeHub和用户模块中定义所需的属性,这些属性将分层在基本部署之上。 分层部署中指定的属性将与基本部署的属性合并。 将基于部署优先级覆盖具有相同路径的属性。 此选项是 --no-validation 的别名。

接受的值: false, true
默认值: False
--login -l

此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。

--metrics -m

IoT Edge 部署用户指标定义。 提供文件路径或原始 json。 用户指标采用 {“queries”:{...}} 的形式 或 {“metrics”:{“queries”:{...}}}。 建议使用 --custom-metric-queries 而不是 --metrics。

--no-validation

禁用边缘部署创建的客户端架构验证。

接受的值: false, true
默认值: False
--pri --priority

在竞争规则(最高胜利)的情况下部署的权重。

默认值: 0
--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--target-condition --tc -t

边缘部署应用于的目标条件。 没有目标条件的部署不会面向任何设备。 使用以下格式:“tags.environment='test'”。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az iot edge deployment delete

删除 IoT Edge 部署。

az iot edge deployment delete --deployment-id
                              [--auth-type {key, login}]
                              [--etag]
                              [--hub-name]
                              [--login]
                              [--resource-group]

必需参数

--deployment-id -d

目标部署名称。 允许小写和以下特殊字符:[-+%_*!']。

可选参数

--auth-type

指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type=<auth-type-value>

接受的值: key, login
默认值: key
--etag -e

对应于资源最后状态的 Etag 或实体标记。 如果未提供 etag,则使用值“*”。

--hub-name -n

IoT 中心名称或主机名。 如果未提供 --login,则为必需。

--login -l

此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az iot edge deployment list

列出IoT 中心中的 IoT Edge 部署。

az iot edge deployment list [--auth-type {key, login}]
                            [--hub-name]
                            [--login]
                            [--resource-group]
                            [--top]

可选参数

--auth-type

指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type=<auth-type-value>

接受的值: key, login
默认值: key
--hub-name -n

IoT 中心名称或主机名。 如果未提供 --login,则为必需。

--login -l

此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--top

要返回的最大部署数。 默认情况下,返回所有部署。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az iot edge deployment show

获取 IoT Edge 部署的详细信息。

az iot edge deployment show --deployment-id
                            [--auth-type {key, login}]
                            [--hub-name]
                            [--login]
                            [--resource-group]

必需参数

--deployment-id -d

目标部署名称。 允许小写和以下特殊字符:[-+%_*!']。

可选参数

--auth-type

指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type=<auth-type-value>

接受的值: key, login
默认值: key
--hub-name -n

IoT 中心名称或主机名。 如果未提供 --login,则为必需。

--login -l

此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az iot edge deployment show-metric

评估 IoT Edge 部署中定义的目标系统指标。

az iot edge deployment show-metric --deployment-id
                                   --metric-id
                                   [--auth-type {key, login}]
                                   [--hub-name]
                                   [--login]
                                   [--metric-type {system, user}]
                                   [--resource-group]

示例

评估“appliedCount”系统指标

az iot edge deployment show-metric -m appliedCount -d {deployment_name} -n {iothub_name} --mt system

评估“myCustomMetric”用户指标

az iot edge deployment show-metric -m myCustomMetric -d {deployment_name} -n {iothub_name}

必需参数

--deployment-id -d

目标部署名称。 允许小写和以下特殊字符:[-+%_*!']。

--metric-id -m

用于评估的目标指标。

可选参数

--auth-type

指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type=<auth-type-value>

接受的值: key, login
默认值: key
--hub-name -n

IoT 中心名称或主机名。 如果未提供 --login,则为必需。

--login -l

此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。

--metric-type --mt

指示应使用哪个指标集合查找指标。

接受的值: system, user
默认值: user
--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az iot edge deployment update

更新 IoT Edge 部署的指定属性。

使用 --set 后跟属性分配来更新部署。

注意:IoT Edge 部署内容是不可变的。 可更新的部署属性是“标签”、“指标”、“优先级”和“targetCondition”。

az iot edge deployment update --deployment-id
                              [--add]
                              [--auth-type {key, login}]
                              [--etag]
                              [--force-string]
                              [--hub-name]
                              [--login]
                              [--remove]
                              [--resource-group]
                              [--set]

示例

更改现有边缘部署的标签和目标条件

az iot edge deployment update -d {deployment_name} -n {iothub_name} --set labels='{"purpose":"dev", "owners":"IoTEngineering"}' targetCondition='tags.building=9'

必需参数

--deployment-id -d

目标部署名称。 允许小写和以下特殊字符:[-+%_*!']。

可选参数

--add

通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>

默认值: []
--auth-type

指示操作是应自动派生策略密钥还是使用当前的 Azure AD 会话。 如果身份验证类型为登录,并且提供资源主机名,则除非需要,否则将跳过资源查找。可以使用 < a0/a0> 配置默认值 az configure --defaults iothub-data-auth-type=<auth-type-value>

接受的值: key, login
默认值: key
--etag -e

对应于资源最后状态的 Etag 或实体标记。 如果未提供 etag,则使用值“*”。

--force-string

使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。

默认值: False
--hub-name -n

IoT 中心名称或主机名。 如果未提供 --login,则为必需。

--login -l

此命令支持具有执行操作权限的实体连接字符串。 用于避免通过“az login”进行会话登录。 如果同时提供实体连接字符串和名称,则连接字符串优先。 如果未提供 --hub-name,则为必需。

--remove

从列表中删除属性或元素。 示例: --remove property.list <indexToRemove> OR --remove propertyToRemove.

默认值: []
--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--set

通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>

默认值: []
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。