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
Target device configuration name. Lowercase and the following special characters are allowed: [-+%_*!'].
Device configuration content. Provide file path or raw json.
Optional Parameters
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}
.
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".
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 *".
IoT Hub name or hostname. Required if --login is not provided.
Map of labels to be applied to target configuration. Using --custom-labels instead of --labels is recommended.Format example: {"key0":"value0", "key1":"value1"}.
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.
Device configuration metric definitions. Provide file path or raw json.Using --custom-metric-queries instead of --metrics is recommended.
Weight of the device configuration in case of competing rules (highest wins).
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
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
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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
Target device configuration name. Lowercase and the following special characters are allowed: [-+%_*!'].
Optional Parameters
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}
.
Etag or entity tag corresponding to the last state of the resource. If no etag is provided the value '*' is used.
IoT Hub name or hostname. Required if --login is not provided.
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.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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
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}
.
IoT Hub name or hostname. Required if --login is not provided.
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.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Maximum number of configurations to return. By default all configurations are returned.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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
Target device configuration name. Lowercase and the following special characters are allowed: [-+%_*!'].
Optional Parameters
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}
.
IoT Hub name or hostname. Required if --login is not provided.
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.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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
Target device configuration name. Lowercase and the following special characters are allowed: [-+%_*!'].
Target metric for evaluation.
Optional Parameters
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}
.
IoT Hub name or hostname. Required if --login is not provided.
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.
Indicates which metric collection should be used to lookup a metric.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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
Target device configuration name. Lowercase and the following special characters are allowed: [-+%_*!'].
Optional Parameters
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>
.
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}
.
Etag or entity tag corresponding to the last state of the resource. If no etag is provided the value '*' is used.
When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
IoT Hub name or hostname. Required if --login is not provided.
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 a property or an element from a list. Example: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Azure CLI