Share via


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

Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--deployment-id -d
Experimental Preview Deprecated

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

Optional Parameters

--auth-type
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--lab --labels
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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
Experimental Preview Deprecated

Disables client side schema validation for edge deployment creation.

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

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

Default value: 0
--resource-group -g
Experimental Preview Deprecated

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

--target-condition --tc -t
Experimental Preview Deprecated

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
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

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

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

--subscription
Experimental Preview Deprecated

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

--verbose
Experimental Preview Deprecated

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

az iot edge deployment delete

Experimental Preview Deprecated

Delete an IoT Edge deployment.

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

Examples

Required Parameters

--deployment-id -d
Experimental Preview Deprecated

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

Optional Parameters

--auth-type
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--hub-name -n
Experimental Preview Deprecated

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

--login -l
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

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

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

--subscription
Experimental Preview Deprecated

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

--verbose
Experimental Preview Deprecated

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

az iot edge deployment list

Experimental Preview Deprecated

List IoT Edge deployments in an IoT Hub.

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

Examples

Required Parameters

Optional Parameters

--auth-type
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--login -l
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--top
Experimental Preview Deprecated

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

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

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

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

--subscription
Experimental Preview Deprecated

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

--verbose
Experimental Preview Deprecated

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

az iot edge deployment show

Experimental Preview Deprecated

Get the details of an IoT Edge deployment.

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

Examples

Required Parameters

--deployment-id -d
Experimental Preview Deprecated

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

Optional Parameters

--auth-type
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--login -l
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

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

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

--subscription
Experimental Preview Deprecated

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

--verbose
Experimental Preview Deprecated

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

az iot edge deployment show-metric

Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--metric-id -m
Experimental Preview Deprecated

Target metric for evaluation.

Optional Parameters

--auth-type
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--login -l
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

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

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

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

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

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

--subscription
Experimental Preview Deprecated

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

--verbose
Experimental Preview Deprecated

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

az iot edge deployment update

Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

Optional Parameters

--add
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

--force-string
Experimental Preview Deprecated

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

Default value: False
--hub-name -n
Experimental Preview Deprecated

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

--login -l
Experimental Preview Deprecated

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
Experimental Preview Deprecated

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

Default value: []
--resource-group -g
Experimental Preview Deprecated

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

--set
Experimental Preview Deprecated

Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>.

Default value: []
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

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

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

--subscription
Experimental Preview Deprecated

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

--verbose
Experimental Preview Deprecated

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