共用方式為


Add-AzIotHubConfiguration

在目標 IoT 中樞 中新增IoT自動裝置管理設定。

語法

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

設定內容是 json,而且會根據裝置或模組意圖而稍有不同。 裝置組態的格式為 {“deviceContent”:{...}} 模組組態的格式為 {“moduleContent”:{...}} 您可以使用使用者提供的計量來定義組態,以進行隨選評估。 用戶計量為 json,格式為 {“query”:{...}} 或 {“metrics”:{“queries”:{...}}}。

注意:模組的目標條件必須以 「from devices.modules where」 開頭。 如需相關資訊,請參閱 https://learn.microsoft.com/azure/iot-hub/iot-hub-automatic-device-management

範例

範例 1

Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1"

使用預設元數據建立裝置組態。

範例 2

Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -Priority 3 -TargetCondition "tags.building=9 and tags.environment='test'"

建立優先順序為 3 的裝置組態,該組態會在裝置在建築物 9 中標記且環境為「測試」時套用條件。

範例 3

$metrics = @{}
$metrics.add("query1", "select deviceId from devices where tags.location='US'")
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -Metric $metrics

使用用戶計量建立裝置組態。

範例 4

$labels = @{}
$labels.add("key0","value0")
$labels.add("key1","value1")
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -Label $labels

使用標籤建立裝置組態。

範例 5

$prop = @{}
$prop.add("Location", "US")
$content = @{}
$content.add("properties.desired.Region", $prop)
Add-AzIotHubConfiguration -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -Name "config1" -DeviceContent $content

使用內容建立裝置組態。

參數

-Confirm

執行 Cmdlet 之前先提示您確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。

類型:IAzureContextContainer
別名:AzContext, AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DeviceContent

IotHub 裝置的設定。

類型:Hashtable
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-InputObject

IotHub 物件

類型:PSIotHub
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-IotHubName

IoT 中樞的名稱

類型:String
Position:1
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Label

要套用至目標組態的標籤對應。

類型:Hashtable
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Metric

查詢組態計量定義的集合。

類型:Hashtable
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Name

組態的標識碼。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Priority

在競爭規則(最高獲勝)的情況下,裝置組態的權數。

類型:Int32
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ResourceGroupName

資源群組的名稱

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-ResourceId

IotHub 資源標識碼

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-TargetCondition

裝置組態套用的目標條件。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

類型:SwitchParameter
別名:wi
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

PSIotHub

String

輸出

PSConfiguration