Κοινή χρήση μέσω


az iot edge deployment

Note

This reference is part of the azure-iot extension for the Azure CLI (version 2.46.0 or higher). The extension will automatically install the first time you run an az iot edge deployment command. Learn more about extensions.

Manage IoT Edge deployments at scale.

Commands

Name Description Type Status
az iot edge deployment create

Create an IoT Edge deployment in a target IoT Hub.

Extension GA
az iot edge deployment delete

Delete an IoT Edge deployment.

Extension GA
az iot edge deployment list

List IoT Edge deployments in an IoT Hub.

Extension GA
az iot edge deployment show

Get the details of an IoT Edge deployment.

Extension GA
az iot edge deployment show-metric

Evaluate a target system metric defined in an IoT Edge deployment.

Extension GA
az iot edge deployment update

Update specified properties of an IoT Edge deployment.

Extension GA

az iot edge deployment create

Create an IoT Edge deployment in a target IoT Hub.

Deployment content is json and in the form of {"modulesContent":{...}} or {"content":{"modulesContent":{...}}}.

By default properties of system modules $edgeAgent and $edgeHub are validated against schemas installed with the IoT extension. This validation is intended for base deployments. If the corresponding schema is not available or base deployment format is not detected, this step will be skipped. Schema validation can be disabled by using the --no-validation switch.

An edge deployment is classified as layered if a module has properties.desired.* defined. Any edge device targeted by a layered deployment, first needs a base deployment applied to it.

Any layered deployments targeting a device must have a higher priority than the base deployment for that device.

Note: If the properties.desired field of a module twin is set in a layered deployment, properties.desired will overwrite the desired properties for that module in any lower priority deployments.

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]

Examples

Create a deployment with labels (bash syntax example) that applies for devices in 'building 9' and the environment is '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

Create a deployment with labels (powershell syntax example) that applies for devices tagged with environment 'dev'.

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

Create a layered deployment that applies for devices tagged with environment 'dev'. Both user metrics and modules content defined inline (powershell syntax example). Note that this is in layered deployment format as properties.desired.* has been defined.

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'}}"

Create a layered deployment that applies for devices in 'building 9' and environment 'test'. Both user metrics and modules content defined inline (bash syntax example). Note that this is in layered deployment format as properties.desired.* has been defined.

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"}}'

Create a deployment that applies for devices in 'building 9' and environment 'test'. Both user metrics and modules content defined from file.

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

Create a deployment whose definition is from file with shell-agnostic input of labels and metrics.

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 *"

Required Parameters

--content -k

IoT Edge deployment content. Provide file path or raw json.

--deployment-id -d

Target deployment name. Lowercase and the following special characters are allowed: [-+%_*!'].

Optional Parameters

--auth-type

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

Accepted values: key, login
Default value: key
--cl --custom-labels

An alternative input style (space separated key=value pairs) for --labels and intended to replace it in the future. Format example: key1=value1 key2="this is my value".

--cmq --custom-metric-queries

An alternative input style (space separated key=value pairs) for --metrics and intended to replace it in the future. Format example: metric1="select deviceId from devices where tags.location='US'" metric2="select *".

--hub-name -n

IoT Hub name or hostname. Required if --login is not provided.

--lab --labels

Map of labels to be applied to target deployment. Use the following format: '{"key0":"value0", "key1":"value1"}'. Using --custom-labels instead of --labels is recommended.

--layered

Layered deployments allow you to define desired properties in $edgeAgent, $edgeHub and user modules that will layer on top of a base deployment. The properties specified in a layered deployment will merge with properties of the base deployment. Properties with the same path will be overwritten based on deployment priority. This option is an alias for --no-validation.

Accepted values: false, true
Default value: False
--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. Required if --hub-name is not provided.

--metrics -m

IoT Edge deployment user metric definitions. Provide file path or raw json. User metrics are in the form of {"queries":{...}} or {"metrics":{"queries":{...}}}. Using --custom-metric-queries instead of --metrics is recommended.

--no-validation

Disables client side schema validation for edge deployment creation.

Accepted values: false, true
Default value: False
--pri --priority

Weight of deployment in case of competing rules (highest wins).

Default value: 0
--resource-group -g

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

--target-condition --tc -t

Target condition in which an edge deployment applies to. Deployments with no target condition will target no device. Use the following format: "tags.environment='test'".

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az iot edge deployment delete

Delete an IoT Edge deployment.

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

Required Parameters

--deployment-id -d

Target deployment name. Lowercase and the following special characters are allowed: [-+%_*!'].

Optional Parameters

--auth-type

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

Accepted values: key, login
Default value: key
--etag -e

Etag or entity tag corresponding to the last state of the resource. If no etag is provided the value '*' is used.

--hub-name -n

IoT Hub name or hostname. Required if --login is not provided.

--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. Required if --hub-name is not provided.

--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az iot edge deployment list

List IoT Edge deployments in an IoT Hub.

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

Optional Parameters

--auth-type

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

Accepted values: key, login
Default value: key
--hub-name -n

IoT Hub name or hostname. Required if --login is not provided.

--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. Required if --hub-name is not provided.

--resource-group -g

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

--top

Maximum number of deployments to return. By default all deployments are returned.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az iot edge deployment show

Get the details of an IoT Edge deployment.

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

Required Parameters

--deployment-id -d

Target deployment name. Lowercase and the following special characters are allowed: [-+%_*!'].

Optional Parameters

--auth-type

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

Accepted values: key, login
Default value: key
--hub-name -n

IoT Hub name or hostname. Required if --login is not provided.

--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. Required if --hub-name is not provided.

--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az iot edge deployment show-metric

Evaluate a target system metric defined in an IoT Edge deployment.

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

Examples

Evaluate the 'appliedCount' system metric

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

Evaluate the 'myCustomMetric' user metric

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

Required Parameters

--deployment-id -d

Target deployment name. Lowercase and the following special characters are allowed: [-+%_*!'].

--metric-id -m

Target metric for evaluation.

Optional Parameters

--auth-type

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

Accepted values: key, login
Default value: key
--hub-name -n

IoT Hub name or hostname. Required if --login is not provided.

--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. Required if --hub-name is not provided.

--metric-type --mt

Indicates which metric collection should be used to lookup a metric.

Accepted values: system, user
Default value: user
--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az iot edge deployment update

Update specified properties of an IoT Edge deployment.

Use --set followed by property assignments for updating a deployment.

Note: IoT Edge deployment content is immutable. Deployment properties that can be updated are 'labels', 'metrics', 'priority' and 'targetCondition'.

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

Examples

Alter the labels and target condition of an existing edge deployment

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

Required Parameters

--deployment-id -d

Target deployment name. Lowercase and the following special characters are allowed: [-+%_*!'].

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

Default value: []
--auth-type

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

Accepted values: key, login
Default value: key
--etag -e

Etag or entity tag corresponding to the last state of the resource. If no etag is provided the value '*' is used.

--force-string

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

Default value: False
--hub-name -n

IoT Hub name or hostname. Required if --login is not provided.

--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. Required if --hub-name is not provided.

--remove

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

Default value: []
--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=<value>.

Default value: []
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.