@@ -248,13 +248,43 @@ function Test-Table
248
248
{
249
249
$storageAccountKeyValue = $ (Get-AzStorageAccountKey - ResourceGroupName $ResourceGroupName - Name $StorageAccountName )[0 ].Value
250
250
$storageContext = New-AzStorageContext - StorageAccountName $StorageAccountName - StorageAccountKey $storageAccountKeyValue
251
-
251
+
252
+ # Create Table
252
253
$tableName = " tabletest"
253
254
New-AzStorageTable - Name $tableName - Context $storageContext
254
255
$table = Get-AzStorageTable - Name $tableName - Context $storageContext
255
256
Assert-AreEqual $table.Count 1
256
257
Assert-AreEqual $table [0 ].Name $tableName
257
258
259
+ # Test run Table query - Insert Entity
260
+ $partitionKey = " p123"
261
+ $rowKey = " row123"
262
+ $entity = New-Object - TypeName Microsoft.Azure.Cosmos.Table.DynamicTableEntity - ArgumentList $partitionKey , $rowKey
263
+ $entity.Properties.Add (" Name" , " name1" )
264
+ $entity.Properties.Add (" ID" , 4567 )
265
+ $result = $table.CloudTable.ExecuteAsync ([Microsoft.Azure.Cosmos.Table.TableOperation ]::Insert($entity ))
266
+
267
+ # Create Table Object - which reference to exist Table with SAS
268
+ $tableSASUri = New-AzureStorageTableSASToken - Name $tablename - Permission " raud" - ExpiryTime (([DateTime ]::UtcNow.AddDays(10 ))) - FullUri - Context $storageContext
269
+ $uri = [System.Uri ]$tableSASUri
270
+ $sasTable = New-Object - TypeName Microsoft.Azure.Cosmos.Table.CloudTable $uri
271
+
272
+ # Test run Table query - Query Entity
273
+ $query = New-Object Microsoft.Azure.Cosmos.Table.TableQuery
274
+ # # Define columns to select.
275
+ $list = New-Object System.Collections.Generic.List[string ]
276
+ $list.Add (" RowKey" )
277
+ $list.Add (" ID" )
278
+ $list.Add (" Name" )
279
+ # # Set query details.
280
+ $query.FilterString = " ID gt 0"
281
+ $query.SelectColumns = $list
282
+ $query.TakeCount = 20
283
+ # # Execute the query.
284
+ $result = $sasTable.ExecuteQuerySegmentedAsync ($query , $null )
285
+ Assert-AreEqual $result.Result.Results.Count 1
286
+
287
+ # Get/Remove Table
258
288
$tableCount1 = (Get-AzStorageTable - Context $storageContext ).Count
259
289
Remove-AzStorageTable - Name $tableName - Force - Context $storageContext
260
290
$table2 = Get-AzStorageTable - Context $storageContext
@@ -370,18 +400,22 @@ function Test-Common
370
400
{
371
401
$storageAccountKeyValue = $ (Get-AzStorageAccountKey - ResourceGroupName $ResourceGroupName - Name $StorageAccountName )[0 ].Value
372
402
$storageContext = New-AzStorageContext - StorageAccountName $StorageAccountName - StorageAccountKey $storageAccountKeyValue
403
+
404
+ # wait at most 120*5s=600s for the set sevice proeprty updated on server.
405
+ $retryTimes = 120
373
406
407
+ # B/F/Q Service properties, in same code path
374
408
$version = " 1.0"
375
409
$retentionDays = 2
376
410
$LoggingOperations = " All"
377
411
378
412
Set-AzStorageServiceLoggingProperty - ServiceType blob - RetentionDays $retentionDays - Version $version - LoggingOperations $LoggingOperations - Context $storageContext
379
413
$i = 0
380
414
$propertyUpdated = $false
381
- while (($i -lt 120 ) -and ($propertyUpdated -eq $false ))
415
+ while (($i -lt $retryTimes ) -and ($propertyUpdated -eq $false ))
382
416
{
383
417
$property = Get-AzStorageServiceLoggingProperty - ServiceType blob - Context $storageContext
384
- if (($property.RetentionDays -eq $retentionDays + 1 ) -and ($property.Version -eq $version ) -and ($property.LoggingOperations -eq $LoggingOperations ))
418
+ if (($property.RetentionDays -eq $retentionDays ) -and ($property.Version -eq $version ) -and ($property.LoggingOperations -eq $LoggingOperations ))
385
419
{
386
420
$propertyUpdated = $true
387
421
}
@@ -400,10 +434,10 @@ function Test-Common
400
434
Set-AzStorageServiceMetricsProperty - ServiceType blob - Version $version - MetricsType Hour - RetentionDays $retentionDays - MetricsLevel $MetricsLevel - Context $storageContext
401
435
$i = 0
402
436
$propertyUpdated = $false
403
- while (($i -lt 120 ) -and ($propertyUpdated -eq $false ))
437
+ while (($i -lt $retryTimes ) -and ($propertyUpdated -eq $false ))
404
438
{
405
- $property = Get-AzStorageServiceLoggingProperty - ServiceType blob - Context $storageContext
406
- if (($property.RetentionDays -eq $retentionDays + 1 ) -and ($property.Version -eq $version ) -and ($property.MetricsLevel.ToString () -eq $MetricsLevel ))
439
+ $property = Get-AzStorageServiceMetricsProperty - ServiceType Blob - MetricsType Hour - Context $storageContext
440
+ if (($property.RetentionDays -eq $retentionDays ) -and ($property.Version -eq $version ) -and ($property.MetricsLevel.ToString () -eq $MetricsLevel ))
407
441
{
408
442
$propertyUpdated = $true
409
443
}
@@ -431,7 +465,7 @@ function Test-Common
431
465
AllowedMethods = @ (" Put" )})
432
466
$i = 0
433
467
$corsRuleUpdated = $false
434
- while (($i -lt 120 ) -and ($corsRuleUpdated -eq $false ))
468
+ while (($i -lt $retryTimes ) -and ($corsRuleUpdated -eq $false ))
435
469
{
436
470
$cors = Get-AzStorageCORSRule - ServiceType blob - Context $storageContext
437
471
if ($cors.Count -eq 2 )
@@ -450,7 +484,7 @@ function Test-Common
450
484
Remove-AzStorageCORSRule - ServiceType blob - Context $storageContext
451
485
$i = 0
452
486
$corsRuleUpdated = $false
453
- while (($i -lt 120 ) -and ($corsRuleUpdated -eq $false ))
487
+ while (($i -lt $retryTimes ) -and ($corsRuleUpdated -eq $false ))
454
488
{
455
489
$cors = Get-AzStorageCORSRule - ServiceType blob - Context $storageContext
456
490
if ($cors.Count -eq 0 )
@@ -464,7 +498,97 @@ function Test-Common
464
498
}
465
499
}
466
500
$cors = Get-AzStorageCORSRule - ServiceType blob - Context $storageContext
467
- Assert-AreEqual 0 $cors.Count
501
+ Assert-AreEqual 0 $cors.Count
502
+
503
+ # Table Service properties
504
+ $version = " 1.0"
505
+ $retentionDays = 3
506
+ $LoggingOperations = " Delete"
507
+
508
+ Set-AzStorageServiceLoggingProperty - ServiceType table - RetentionDays $retentionDays - Version $version - LoggingOperations $LoggingOperations - Context $storageContext
509
+ $i = 0
510
+ $propertyUpdated = $false
511
+ while (($i -lt $retryTimes ) -and ($propertyUpdated -eq $false ))
512
+ {
513
+ $property = Get-AzStorageServiceLoggingProperty - ServiceType table - Context $storageContext
514
+ if (($property.RetentionDays -eq $retentionDays ) -and ($property.Version -eq $version ) -and ($property.LoggingOperations -eq $LoggingOperations ))
515
+ {
516
+ $propertyUpdated = $true
517
+ }
518
+ else
519
+ {
520
+ sleep 5
521
+ $i = $i + 5
522
+ }
523
+ }
524
+ $property = Get-AzStorageServiceLoggingProperty - ServiceType table - Context $storageContext
525
+ Assert-AreEqual $LoggingOperations $property.LoggingOperations.ToString ()
526
+ Assert-AreEqual $version $property.Version
527
+ Assert-AreEqual $retentionDays $property.RetentionDays
528
+
529
+ $MetricsLevel = " ServiceAndApi"
530
+ Set-AzStorageServiceMetricsProperty - ServiceType table - Version $version - MetricsType Minute - RetentionDays $retentionDays - MetricsLevel $MetricsLevel - Context $storageContext
531
+ $i = 0
532
+ $propertyUpdated = $false
533
+ while (($i -lt $retryTimes ) -and ($propertyUpdated -eq $false ))
534
+ {
535
+ $property = Get-AzStorageServiceMetricsProperty - ServiceType table - MetricsType Minute - Context $storageContext
536
+ if (($property.RetentionDays -eq $retentionDays ) -and ($property.Version -eq $version ) -and ($property.MetricsLevel.ToString () -eq $MetricsLevel ))
537
+ {
538
+ $propertyUpdated = $true
539
+ }
540
+ else
541
+ {
542
+ sleep 5
543
+ $i = $i + 5
544
+ }
545
+ }
546
+ $property = Get-AzStorageServiceMetricsProperty - ServiceType table - MetricsType Minute - Context $storageContext
547
+ Assert-AreEqual $MetricsLevel $property.MetricsLevel.ToString ()
548
+ Assert-AreEqual $version $property.Version
549
+ Assert-AreEqual $retentionDays $property.RetentionDays
550
+
551
+ Set-AzStorageCORSRule - ServiceType table - Context $storageContext - CorsRules (@ {
552
+ AllowedHeaders = @ (" x-ms-blob-content-type" );
553
+ AllowedOrigins = @ (" *" );
554
+ MaxAgeInSeconds = 20 ;
555
+ AllowedMethods = @ (" Get" , " Connect" )})
556
+ $i = 0
557
+ $corsRuleUpdated = $false
558
+ while (($i -lt $retryTimes ) -and ($corsRuleUpdated -eq $false ))
559
+ {
560
+ $cors = Get-AzStorageCORSRule - ServiceType table - Context $storageContext
561
+ if ($cors.Count -eq 1 )
562
+ {
563
+ $corsRuleUpdated = $true
564
+ }
565
+ else
566
+ {
567
+ sleep 5
568
+ $i = $i + 5
569
+ }
570
+ }
571
+ $cors = Get-AzStorageCORSRule - ServiceType table - Context $storageContext
572
+ Assert-AreEqual 1 $cors.Count
573
+
574
+ Remove-AzStorageCORSRule - ServiceType table - Context $storageContext
575
+ $i = 0
576
+ $corsRuleUpdated = $false
577
+ while (($i -lt $retryTimes ) -and ($corsRuleUpdated -eq $false ))
578
+ {
579
+ $cors = Get-AzStorageCORSRule - ServiceType table - Context $storageContext
580
+ if ($cors.Count -eq 0 )
581
+ {
582
+ $corsRuleUpdated = $true
583
+ }
584
+ else
585
+ {
586
+ sleep 5
587
+ $i = $i + 5
588
+ }
589
+ }
590
+ $cors = Get-AzStorageCORSRule - ServiceType table - Context $storageContext
591
+ Assert-AreEqual 0 $cors.Count
468
592
}
469
593
finally
470
594
{
0 commit comments