Skip to content

Commit cfca026

Browse files
authored
Add Tag option in create IotHub cmdlet (#13352)
1 parent c63a5ce commit cfca026

File tree

5 files changed

+1765
-1921
lines changed

5 files changed

+1765
-1921
lines changed

src/IotHub/IotHub.Test/ScenarioTests/IotHubTests.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ function Test-AzureRmIotHubLifecycle
8888
$routingProperties.Routes = New-Object 'System.Collections.Generic.List[Microsoft.Azure.Commands.Management.IotHub.Models.PSRouteMetadata]'
8989
$routingProperties.Routes.Add($routeProp)
9090
$properties.Routing = $routingProperties
91-
$newIothub1 = New-AzIotHub -Name $IotHubName -ResourceGroupName $ResourceGroupName -Location $Location -SkuName $Sku -Units 1 -Properties $properties
91+
92+
# Add Tags to Iot Hub
93+
$tags = @{}
94+
$tags.Add($Tag1Key, $Tag1Value)
95+
96+
# Create new Iot Hub
97+
$newIothub1 = New-AzIotHub -Name $IotHubName -ResourceGroupName $ResourceGroupName -Location $Location -SkuName $Sku -Units 1 -Properties $properties -tag $tags
9298

9399
# Get Iot Hub in resourcegroup
94100
$allIotHubsInResourceGroup = Get-AzIotHub -ResourceGroupName $ResourceGroupName
@@ -103,6 +109,8 @@ function Test-AzureRmIotHubLifecycle
103109
Assert-True { $iotHub.Properties.Routing.Routes.Count -eq 1}
104110
Assert-True { $iotHub.Properties.Routing.Routes[0].Name -eq "route"}
105111
Assert-True { $iotHub.Properties.Routing.Endpoints.EventHubs[0].Name -eq "eh1"}
112+
Assert-True { $iotHub.Tags.Count -eq 1 }
113+
Assert-True { $iotHub.Tags.Item($Tag1Key) -eq $Tag1Value }
106114

107115
# Get Quota Metrics
108116
$quotaMetrics = Get-AzIotHubQuotaMetric -ResourceGroupName $ResourceGroupName -Name $IotHubName
@@ -238,13 +246,6 @@ function Test-AzureRmIotHubLifecycle
238246
$iotHubUpdated = Set-AzIotHub -ResourceGroupName $ResourceGroupName -Name $IotHubName -FallbackRoute $iothub.Properties.Routing.FallbackRoute
239247
Assert-True { $iotHubUpdated.Properties.Routing.FallbackRoute.IsEnabled -eq 1}
240248

241-
# Add Tags to Iot Hub
242-
$tags = @{}
243-
$tags.Add($Tag1Key, $Tag1Value)
244-
$updatedIotHub = Update-AzIotHub -ResourceGroupName $ResourceGroupName -Name $IotHubName -Tag $tags
245-
Assert-True { $updatedIotHub.Tags.Count -eq 1 }
246-
Assert-True { $updatedIotHub.Tags.Item($Tag1Key) -eq $Tag1Value }
247-
248249
# Add more Tags to Iot Hub
249250
$tags.Clear()
250251
$tags.Add($Tag2Key, $Tag2Value)

0 commit comments

Comments
 (0)