@@ -26,7 +26,17 @@ Test Get-AzureRmIotHub for listing all iothubs in a subscription
26
26
27
27
function Test-AzureRmIotHubLifecycle
28
28
{
29
- Param ($Location , $IotHubName , $ResourceGroupName , $Sku )
29
+ $Location = Get-Location " Microsoft.Devices" " IotHub"
30
+ $IotHubName = getAssetName
31
+ $ResourceGroupName = getAssetName
32
+ $Sku = " B1"
33
+ $namespaceName = getAssetName
34
+ $eventHubName = getAssetName
35
+ $authRuleName = getAssetName
36
+ $Tag1Key = " key1"
37
+ $Tag2Key = " key2"
38
+ $Tag1Value = " value1"
39
+ $Tag2Value = " value2"
30
40
31
41
# Get all Iot hubs in the subscription
32
42
$allIotHubs = Get-AzureRmIotHub
@@ -38,7 +48,6 @@ function Test-AzureRmIotHubLifecycle
38
48
$resourceGroup = New-AzureRmResourceGroup - Name $ResourceGroupName - Location $Location
39
49
40
50
Write-Debug " Create new eventHub "
41
- $namespaceName = " IotHubPSEHNamespaceTest"
42
51
$result = New-AzureRmEventHubNamespace - ResourceGroup $ResourceGroupName - NamespaceName $namespaceName - Location $Location
43
52
44
53
Wait-Seconds 15
@@ -47,13 +56,11 @@ function Test-AzureRmIotHubLifecycle
47
56
Assert-True {$result.ProvisioningState -eq " Succeeded" }
48
57
49
58
Write-Debug " Create new eventHub "
50
- $eventHubName = " IotHubPSEHTest"
51
59
$msgRetentionInDays = 3
52
60
$partionCount = 2
53
61
$result = New-AzureRmEventHub - ResourceGroup $ResourceGroupName - NamespaceName $namespaceName - EventHubName $eventHubName - MessageRetentionInDays $msgRetentionInDays - PartitionCount $partionCount
54
62
55
63
# Create AuthRule
56
- $authRuleName = " IotHubPSEHAuthRule"
57
64
$rights = " Listen" , " Send"
58
65
$authRule = New-AzureRmEventHubAuthorizationRule - ResourceGroup $ResourceGroupName - NamespaceName $namespaceName - EventHubName $eventHubName - AuthorizationRuleName $authRuleName - Rights $rights
59
66
$keys = Get-AzureRmEventHubKey - ResourceGroup $ResourceGroupName - NamespaceName $namespaceName - EventHubName $eventHubName - AuthorizationRuleName $authRuleName
@@ -226,13 +233,34 @@ function Test-AzureRmIotHubLifecycle
226
233
$iotHubUpdated = Set-AzureRmIotHub - ResourceGroupName $ResourceGroupName - Name $IotHubName - FallbackRoute $iothub.Properties.Routing.FallbackRoute
227
234
Assert-True { $iotHubUpdated.Properties.Routing.FallbackRoute.IsEnabled -eq 1 }
228
235
236
+ # Add Tags to Iot Hub
237
+ $tags = @ {}
238
+ $tags.Add ($Tag1Key , $Tag1Value )
239
+ $updatedIotHub = Update-AzureRmIotHub - ResourceGroupName $ResourceGroupName - Name $IotHubName - Tag $tags
240
+ Assert-True { $updatedIotHub.Tags.Count -eq 1 }
241
+ Assert-True { $updatedIotHub.Tags.Item ($Tag1Key ) -eq $Tag1Value }
242
+
243
+ # Add more Tags to Iot Hub
244
+ $tags.Clear ()
245
+ $tags.Add ($Tag2Key , $Tag2Value )
246
+ $updatedIotHub = Update-AzureRmIotHub - ResourceGroupName $ResourceGroupName - Name $IotHubName - Tag $tags
247
+ Assert-True { $updatedIotHub.Tags.Count -eq 2 }
248
+ Assert-True { $updatedIotHub.Tags.Item ($Tag1Key ) -eq $Tag1Value }
249
+ Assert-True { $updatedIotHub.Tags.Item ($Tag2Key ) -eq $Tag2Value }
250
+
251
+ # Add Tags to Iot Hub with Reset option
252
+ $tags.Clear ()
253
+ $tags.Add ($Tag1Key , $Tag1Value )
254
+ $updatedIotHub = Update-AzureRmIotHub - ResourceGroupName $ResourceGroupName - Name $IotHubName - Tag $tags - Reset
255
+ Assert-True { $updatedIotHub.Tags.Count -eq 1 }
256
+ Assert-True { $updatedIotHub.Tags.Item ($Tag1Key ) -eq $Tag1Value }
257
+
229
258
# Remove IotHub
230
259
Remove-AzureRmIotHub - ResourceGroupName $ResourceGroupName - Name $IotHubName
231
260
}
232
261
233
262
function Test-AzureRmIotHubCertificateLifecycle
234
263
{
235
- # Param($Location, $IotHubName, $ResourceGroupName, $Sku)
236
264
$Location = Get-Location " Microsoft.Devices" " IotHub"
237
265
$IotHubName = getAssetName
238
266
$ResourceGroupName = getAssetName
0 commit comments