Share via


az iot hub configuration

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 hub configuration command. Learn more about extensions.

Manage IoT automatic device management configuration at scale.

Commands

Name Description Type Status
az iot hub configuration create

Create an IoT automatic device management configuration in a target IoT Hub.

Extension GA
az iot hub configuration delete

Delete an IoT device configuration.

Extension GA
az iot hub configuration list

List IoT automatic device management configurations in an IoT Hub.

Extension GA
az iot hub configuration show

Get the details of an IoT automatic device management configuration.

Extension GA
az iot hub configuration show-metric

Evaluate a target user or system metric defined in an IoT device configuration.

Extension GA
az iot hub configuration update

Update specified properties of an IoT automatic device management configuration.

Extension GA

az iot hub configuration create

Create an IoT automatic device management configuration in a target IoT Hub.

Configuration content is json and slighty varies based on device or module intent.

Device configurations are in the form of {"deviceContent":{...}} or {"content":{"deviceContent":{...}}}

Module configurations are in the form of {"moduleContent":{...}} or {"content":{"moduleContent":{...}}}

Configurations can be defined with user provided metrics for on demand evaluation. User metrics are json and in the form of {"queries":{...}} or {"metrics":{"queries":{...}}}.

Note: Target condition for modules must start with "from devices.modules where".

az iot hub configuration create --config-id
                                --content
                                [--auth-type {key, login}]
                                [--cl]
                                [--cmq]
                                [--hub-name]
                                [--lab]
                                [--login]
                                [--metrics]
                                [--pri]
                                [--resource-group]
                                [--target-condition]

Examples

Create a device configuration with a priority of 3 that applies on condition when a device is tagged in building 9 and the environment is 'test'.

az iot hub configuration create -c {config_name} -n {iothub_name} --content device_content.json --target-condition "tags.building=9 and tags.environment='test'" --priority 3

Create a device configuration with labels and provide user metrics inline (bash syntax example).

az iot hub configuration create -c {config_name} -n {iothub_name} --content device_content.json --target-condition "tags.building=9" --labels '{"key0":"value0", "key1":"value1"}' --priority 10 --metrics '{"metrics": {"queries": {"mymetric": "select deviceId from devices where tags.location='US'"}}}'

Create a module configuration with labels and provide user metrics inline (cmd syntax example)

az iot hub configuration create -c {config_name} -n {iothub_name} --content module_content.json --target-condition "from devices.modules where tags.building=9" --labels "{\"key0\":\"value0\", \"key1\":\"value1\"}" --metrics "{\"metrics\": {\"queries\": {\"mymetric\": \"select moduleId from devices.modules where tags.location='US'\"}}}"

Create a module configuration with content and user metrics inline (powershell syntax example).

az iot hub configuration create -c {config_name} -n {iothub_name} --content '{\"moduleContent\": {\"properties.desired.chillerWaterSettings\": {\"temperature\": 38, \"pressure\": 78}}}' --target-condition "from devices.modules where tags.building=9" --priority 1 --metrics '{\"metrics\": {\"queries\": {\"mymetric\":\"select moduleId from devices.modules where tags.location=''US''\"}}}'

Create a device configuration with an alternative input style of labels and metrics (shell agnostic).

az iot hub configuration create -c {config_name} -n {iothub_name} --content device_content.json --target-condition "from devices.modules where tags.building=9" --custom-labels key0="value0" key1="value1" --priority 10 --custom-metric-queries mymetric1="select deviceId from devices where tags.location='US'" mymetric2="select *"

Required Parameters

--config-id -c

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

--content -k

Device configuration content. Provide file path or raw json.

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 configuration. Using --custom-labels instead of --labels is recommended.Format example: {"key0":"value0", "key1":"value1"}.

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

Device configuration metric definitions. Provide file path or raw json.Using --custom-metric-queries instead of --metrics is recommended.

--pri --priority

Weight of the device configuration 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 a device or module configuration applies to. Configurations with no target condition will target no device or module. 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 hub configuration delete

Delete an IoT device configuration.

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

Required Parameters

--config-id -c

Target device configuration 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 hub configuration list

List IoT automatic device management configurations in an IoT Hub.

az iot hub configuration 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 configurations to return. By default all configurations 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 hub configuration show

Get the details of an IoT automatic device management configuration.

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

Required Parameters

--config-id -c

Target device configuration 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 hub configuration show-metric

Evaluate a target user or system metric defined in an IoT device configuration.

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

Examples

Evaluate the user defined 'warningLimit' metric

az iot hub configuration show-metric -m warningLimit -c {configuration_name} -n {iothub_name}

Evaluate the system 'appliedCount' metric

az iot hub configuration show-metric --metric-id appliedCount -c {configuration_name} -n {iothub_name} --metric-type system

Required Parameters

--config-id -c

Target device configuration 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 hub configuration update

Update specified properties of an IoT automatic device management configuration.

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

Note: Configuration content is immutable. Configuration properties that can be updated are 'labels', 'metrics', 'priority' and 'targetCondition'.

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

Examples

Alter the priority of a device configuration and update its target condition

az iot hub configuration update -c {configuration_name} -n {iothub_name} --set priority=10 targetCondition="tags.building=43 and tags.environment='dev'"

Required Parameters

--config-id -c

Target device configuration 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.