@@ -27,7 +27,7 @@ function Test-NewAzureRmCognitiveServicesAccount
27
27
$accountname = ' csa' + $rgname ;
28
28
$skuname = ' S2' ;
29
29
$accounttype = ' TextAnalytics' ;
30
- $loc = ' West US' ;
30
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
31
31
32
32
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
33
33
@@ -57,28 +57,31 @@ function Test-NewAzureRmAllKindsOfCognitiveServicesAccounts
57
57
# Setup
58
58
$rgname = Get-CognitiveServicesManagementTestResourceName ;
59
59
60
+ $locWU = Get-Location - providerNamespace " Microsoft.CognitiveServices" - resourceType " accounts" - preferredLocation " West US" ;
61
+ $locGBL = Get-Location - providerNamespace " Microsoft.CognitiveServices" - resourceType " accounts" - preferredLocation " Global" ;
62
+
60
63
try
61
64
{
62
65
New-AzureRmResourceGroup - Name $rgname - Location ' West US' ;
63
66
64
67
# Create all known kinds of Cognitive Services accounts.
65
- Test-CreateCognitiveServicesAccount $rgname ' AcademicTest' ' Academic' ' S0' ' West US '
66
- Test-CreateCognitiveServicesAccount $rgname ' BingAutosuggestTest' ' Bing.Autosuggest' ' S1' ' Global '
67
- Test-CreateCognitiveServicesAccount $rgname ' BingSearchTest' ' Bing.Search' ' S1' ' Global '
68
- Test-CreateCognitiveServicesAccount $rgname ' BingSpeechTest' ' Bing.Speech' ' S0' ' Global '
69
- Test-CreateCognitiveServicesAccount $rgname ' BingSpellCheckTest' ' Bing.SpellCheck' ' S1' ' Global '
70
- Test-CreateCognitiveServicesAccount $rgname ' ComputerVisionTest' ' ComputerVision' ' S0' ' West US '
71
- Test-CreateCognitiveServicesAccount $rgname ' ContentModeratorTest' ' ContentModerator' ' S0' ' West US '
72
- Test-CreateCognitiveServicesAccount $rgname ' EmotionTest' ' Emotion' ' S0' ' West US '
73
- Test-CreateCognitiveServicesAccount $rgname ' FaceTest' ' Face' ' S0' ' West US '
74
- Test-CreateCognitiveServicesAccount $rgname ' LUISTest' ' LUIS' ' S0' ' West US '
75
- Test-CreateCognitiveServicesAccount $rgname ' RecommendationsTest' ' Recommendations' ' S1' ' West US '
76
- Test-CreateCognitiveServicesAccount $rgname ' SpeakerRecognitionTest' ' SpeakerRecognition' ' S0' ' West US '
77
- Test-CreateCognitiveServicesAccount $rgname ' SpeechTest' ' Speech' ' S0' ' West US '
78
- Test-CreateCognitiveServicesAccount $rgname ' SpeechTranslationTest' ' SpeechTranslation' ' S1' ' Global '
79
- Test-CreateCognitiveServicesAccount $rgname ' TextAnalyticsTest' ' TextAnalytics' ' S1' ' West US '
80
- Test-CreateCognitiveServicesAccount $rgname ' TextTranslationTest' ' TextTranslation' ' S1' ' Global '
81
- Test-CreateCognitiveServicesAccount $rgname ' WebLMTest' ' WebLM' ' S0' ' West US '
68
+ Test-CreateCognitiveServicesAccount $rgname ' AcademicTest' ' Academic' ' S0' $locWU
69
+ Test-CreateCognitiveServicesAccount $rgname ' BingAutosuggestTest' ' Bing.Autosuggest' ' S1' $locGBL
70
+ Test-CreateCognitiveServicesAccount $rgname ' BingSearchTest' ' Bing.Search' ' S1' $locGBL
71
+ Test-CreateCognitiveServicesAccount $rgname ' BingSpeechTest' ' Bing.Speech' ' S0' $locGBL
72
+ Test-CreateCognitiveServicesAccount $rgname ' BingSpellCheckTest' ' Bing.SpellCheck' ' S1' $locGBL
73
+ Test-CreateCognitiveServicesAccount $rgname ' ComputerVisionTest' ' ComputerVision' ' S0' $locWU
74
+ Test-CreateCognitiveServicesAccount $rgname ' ContentModeratorTest' ' ContentModerator' ' S0' $locWU
75
+ Test-CreateCognitiveServicesAccount $rgname ' EmotionTest' ' Emotion' ' S0' $locWU
76
+ Test-CreateCognitiveServicesAccount $rgname ' FaceTest' ' Face' ' S0' $locWU
77
+ Test-CreateCognitiveServicesAccount $rgname ' LUISTest' ' LUIS' ' S0' $locWU
78
+ Test-CreateCognitiveServicesAccount $rgname ' RecommendationsTest' ' Recommendations' ' S1' $locWU
79
+ Test-CreateCognitiveServicesAccount $rgname ' SpeakerRecognitionTest' ' SpeakerRecognition' ' S0' $locWU
80
+ Test-CreateCognitiveServicesAccount $rgname ' SpeechTest' ' Speech' ' S0' $locWU
81
+ Test-CreateCognitiveServicesAccount $rgname ' SpeechTranslationTest' ' SpeechTranslation' ' S1' $locGBL
82
+ Test-CreateCognitiveServicesAccount $rgname ' TextAnalyticsTest' ' TextAnalytics' ' S1' $locWU
83
+ Test-CreateCognitiveServicesAccount $rgname ' TextTranslationTest' ' TextTranslation' ' S1' $locGBL
84
+ Test-CreateCognitiveServicesAccount $rgname ' WebLMTest' ' WebLM' ' S0' $locWU
82
85
}
83
86
finally
84
87
{
@@ -102,7 +105,7 @@ function Test-RemoveAzureRmCognitiveServicesAccount
102
105
$accountname = ' csa' + $rgname ;
103
106
$skuname = ' S1' ;
104
107
$accounttype = ' TextAnalytics' ;
105
- $loc = ' West US' ;
108
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
106
109
107
110
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
108
111
@@ -134,7 +137,7 @@ function Test-GetAzureCognitiveServiceAccount
134
137
$accountname = ' csa' + $rgname ;
135
138
$skuname = ' S2' ;
136
139
$accounttype = ' TextAnalytics' ;
137
- $loc = ' West US' ;
140
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
138
141
139
142
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
140
143
@@ -183,7 +186,7 @@ function Test-SetAzureRmCognitiveServicesAccount
183
186
$accountname = ' csa' + $rgname ;
184
187
$skuname = ' S2' ;
185
188
$accounttype = ' TextAnalytics' ;
186
- $loc = ' West US' ;
189
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
187
190
188
191
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
189
192
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -229,7 +232,7 @@ function Test-GetAzureRmCognitiveServicesAccountKey
229
232
$accountname = ' csa' + $rgname ;
230
233
$skuname = ' S2' ;
231
234
$accounttype = ' TextAnalytics' ;
232
- $loc = ' West US' ;
235
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
233
236
234
237
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
235
238
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -262,7 +265,7 @@ function Test-NewAzureRmCognitiveServicesAccountKey
262
265
$accountname = ' csa' + $rgname ;
263
266
$skuname = ' S2' ;
264
267
$accounttype = ' TextAnalytics' ;
265
- $loc = ' West US' ;
268
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
266
269
267
270
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
268
271
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -305,7 +308,7 @@ function Test-GetAzureRmCognitiveServicesAccountSkus
305
308
$accountname = ' csa' + $rgname ;
306
309
$skuname = ' S2' ;
307
310
$accounttype = ' TextAnalytics' ;
308
- $loc = ' West US' ;
311
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
309
312
310
313
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
311
314
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -340,7 +343,7 @@ function Test-PipingGetAccountToGetKey
340
343
$accountname = ' csa' + $rgname ;
341
344
$skuname = ' S2' ;
342
345
$accounttype = ' TextAnalytics' ;
343
- $loc = ' West US' ;
346
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
344
347
345
348
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
346
349
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -372,7 +375,7 @@ function Test-PipingToSetAzureAccount
372
375
$accountname = ' csa' + $rgname ;
373
376
$skuname = ' S2' ;
374
377
$accounttype = ' TextAnalytics' ;
375
- $loc = ' West US' ;
378
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
376
379
377
380
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
378
381
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -407,7 +410,7 @@ function Test-PipingToGetAccountSkus
407
410
$accountname = ' csa' + $rgname ;
408
411
$skuname = ' S2' ;
409
412
$accounttype = ' TextAnalytics' ;
410
- $loc = ' West US' ;
413
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
411
414
412
415
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
413
416
New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -444,7 +447,7 @@ function Test-MinMaxAccountName
444
447
$longname = ' testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest' ;
445
448
$skuname = ' S2' ;
446
449
$accounttype = ' TextAnalytics' ;
447
- $loc = ' West US' ;
450
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US" ;
448
451
449
452
New-AzureRmResourceGroup - Name $rgname - Location $loc ;
450
453
$shortaccount = New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $shortname - Type $accounttype - SkuName $skuname - Location $loc - Force;
@@ -470,7 +473,7 @@ function Test-GetWithPaging
470
473
{
471
474
# Setup
472
475
$rgname = Get-CognitiveServicesManagementTestResourceName
473
- $loc = ' West US'
476
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices " - resourceType " accounts " - preferredLocation " West US"
474
477
475
478
try
476
479
{
@@ -502,3 +505,47 @@ function Test-GetWithPaging
502
505
Clean - ResourceGroup $rgname
503
506
}
504
507
}
508
+
509
+ <#
510
+ . SYNOPSIS
511
+ Test Test-GetUsages
512
+ #>
513
+ function Test-GetUsages
514
+ {
515
+ # Setup
516
+ $rgname = Get-CognitiveServicesManagementTestResourceName ;
517
+
518
+ try
519
+ {
520
+ # Test
521
+ $accountname = ' csa' + $rgname ;
522
+ $skuname = ' S1' ;
523
+ $accounttype = ' TextAnalytics' ;
524
+ $loc = Get-Location - providerNamespace " Microsoft.CognitiveServices" - resourceType " accounts" - preferredLocation " West US"
525
+
526
+ New-AzureRmResourceGroup - Name $rgname - Location $loc ;
527
+
528
+ $createdAccount = New-AzureRmCognitiveServicesAccount - ResourceGroupName $rgname - Name $accountname - Type $accounttype - SkuName $skuname - Location $loc - Force;
529
+ $usages1 = Get-AzureRmCognitiveServicesAccountUsage - ResourceGroupName $rgname - Name $accountname
530
+ $usages2 = Get-AzureRmCognitiveServicesAccountUsage - InputObject $createdAccount
531
+ $usages3 = Get-AzureRmCognitiveServicesAccountUsage - ResourceId $createdAccount.Id
532
+
533
+ Assert-True {$usages1.Count -gt 0 }
534
+ Assert-AreEqual 0.0 $usages1 [0 ].CurrentValue
535
+ Assert-True {$usages1 [0 ].Limit -gt 0 }
536
+
537
+ Assert-AreEqual $usages1.Count $usages2.Count
538
+ Assert-AreEqual $usages2.Count $usages3.Count
539
+
540
+ Assert-AreEqual $usages1 [0 ].CurrentValue $usages2 [0 ].CurrentValue
541
+ Assert-AreEqual $usages2 [0 ].CurrentValue $usages3 [0 ].CurrentValue
542
+
543
+ Assert-AreEqual $usages1 [0 ].Limit $usages2 [0 ].Limit
544
+ Assert-AreEqual $usages2 [0 ].Limit $usages3 [0 ].Limit
545
+ }
546
+ finally
547
+ {
548
+ # Cleanup
549
+ Clean - ResourceGroup $rgname
550
+ }
551
+ }
0 commit comments