Add-AzIotHubConfiguration
Add an IoT automatic device management configuration in a target IoT Hub.
Syntax
ResourceSet (Default)
Add-AzIotHubConfiguration
[-ResourceGroupName] <String>
[-IotHubName] <String>
-Name <String>
[-DeviceContent <Hashtable>]
[-Priority <Int32>]
[-TargetCondition <String>]
[-Metric <Hashtable>]
[-Label <Hashtable>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Add-AzIotHubConfiguration
[-InputObject] <PSIotHub>
-Name <String>
[-DeviceContent <Hashtable>]
[-Priority <Int32>]
[-TargetCondition <String>]
[-Metric <Hashtable>]
[-Label <Hashtable>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ResourceIdSet
Add-AzIotHubConfiguration
[-ResourceId] <String>
-Name <String>
[-DeviceContent <Hashtable>]
[-Priority <Int32>]
[-TargetCondition <String>]
[-Metric <Hashtable>]
[-Label <Hashtable>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Configuration content is json and slightly varies based on device or module intent.
Device configurations are in the form of {"deviceContent":{...}}
Module configurations are in the form of {"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". See https://learn.microsoft.com/azure/iot-hub/iot-hub-automatic-device-management for more information.
Examples
Example 1
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1"
Create a device configuration with default metadata.
Example 2
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -Priority 3 -TargetCondition "tags.building=9 and tags.environment='test'"
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'.
Example 3
$metrics = @{}
$metrics.add("query1", "select deviceId from devices where tags.location='US'")
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -Metric $metrics
Create a device configuration with user metrics.
Example 4
$labels = @{}
$labels.add("key0","value0")
$labels.add("key1","value1")
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -Label $labels
Create a device configuration with labels.
Example 5
$prop = @{}
$prop.add("Location", "US")
$content = @{}
$content.add("properties.desired.Region", $prop)
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -DeviceContent $content
Create a device configuration with content.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DeviceContent
Configuration for IotHub devices.
Parameter properties
Type: Hashtable
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
IotHub object
Type: PSIotHub
Default value: None
Supports wildcards: False
DontShow: False
InputObjectSet
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-IotHubName
Name of the Iot Hub
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ResourceSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Label
Map of labels to be applied to target configuration.
Parameter properties
Type: Hashtable
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Metric
Queries collection for configuration metrics definition.
Parameter properties
Type: Hashtable
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Name
Identifier for the configuration.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Priority
Weight of the device configuration in case of competing rules (highest wins).
Parameter properties
Type: Int32
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
Name of the Resource Group
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ResourceSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceId
IotHub Resource Id
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ResourceIdSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-TargetCondition
Target condition in which a device configuration applies to.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs