你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Add-AzIotHubConfiguration
Add an IoT automatic device management configuration in a target IoT Hub.
Syntax
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>]
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 slighty 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.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DeviceContent
Configuration for IotHub devices.
Type: | Hashtable |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InputObject
IotHub object
Type: | PSIotHub |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-IotHubName
Name of the Iot Hub
Type: | String |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Label
Map of labels to be applied to target configuration.
Type: | Hashtable |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Metric
Queries collection for configuration metrics definition.
Type: | Hashtable |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
Identifier for the configuration.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Priority
Weight of the device configuration in case of competing rules (highest wins).
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
Name of the Resource Group
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceId
IotHub Resource Id
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TargetCondition
Target condition in which a device configuration applies to.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |