Skip to content

[Storage] Support new SRP features on new API version 2021-06-01 #15945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ function Test-SetAzureStorageAccount
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
$loc = Get-ProviderLocation ResourceManagement;
$loc = Get-ProviderLocation_Canary ResourceManagement;
$kind = 'StorageV2'

New-AzResourceGroup -Name $rgname -Location $loc;
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind -EnableHttpsTrafficOnly $true -EnableHierarchicalNamespace $true;
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind -EnableHttpsTrafficOnly $true -EnableHierarchicalNamespace $true -PublicNetworkAccess Disabled;

Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
Assert-AreEqual $stoname $sto.StorageAccountName;
Expand All @@ -217,6 +217,7 @@ function Test-SetAzureStorageAccount
Assert-AreEqual $kind $sto.Kind;
Assert-AreEqual $true $sto.EnableHttpsTrafficOnly;
Assert-AreEqual $true $sto.EnableHierarchicalNamespace;
Assert-AreEqual Disabled $sto.PublicNetworkAccess;

$stos = Get-AzStorageAccount -ResourceGroupName $rgname;
Assert-AreEqual $stoname $stos[0].StorageAccountName;
Expand All @@ -225,13 +226,15 @@ function Test-SetAzureStorageAccount
Assert-AreEqual $kind $sto.Kind;
Assert-AreEqual $true $sto.EnableHttpsTrafficOnly;
Assert-AreEqual $true $sto.EnableHierarchicalNamespace;
Assert-AreEqual Disabled $sto.PublicNetworkAccess;

$stotype = 'Standard_LRS';
# TODO: Still need to do retry for Set-, even after Get- returns it.
Retry-IfException { Set-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Type $stotype -EnableHttpsTrafficOnly $false }
Retry-IfException { Set-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Type $stotype -EnableHttpsTrafficOnly $false -PublicNetworkAccess Enabled }
$stotype = 'Standard_RAGRS';
$sto = Set-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Type $stotype;
Assert-AreEqual $true $sto.EnableHierarchicalNamespace;
Assert-AreEqual Enabled $sto.PublicNetworkAccess;

$sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;
Assert-AreEqual $stoname $sto.StorageAccountName;
Expand All @@ -240,6 +243,7 @@ function Test-SetAzureStorageAccount
Assert-AreEqual $kind $sto.Kind;
Assert-AreEqual $false $sto.EnableHttpsTrafficOnly;
Assert-AreEqual $true $sto.EnableHierarchicalNamespace;
Assert-AreEqual Enabled $sto.PublicNetworkAccess;

Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
}
Expand Down Expand Up @@ -1756,7 +1760,7 @@ function Test-StorageBlobInventory
#create rule objects
$rule1 = New-AzStorageBlobInventoryPolicyRule -Name test1 -Disabled -BlobType blockBlob,appendBlob -PrefixMatch abc,edf,eqwewqe,eqwewqreewqe,qwewqewqewqewqewadasd -IncludeSnapshot -IncludeBlobVersion `
-Destination $containerName -Format Parquet -Schedule Weekly `
-BlobSchemaField name,Creation-Time,Last-Modified,Content-Length,Content-MD5,BlobType,AccessTier,AccessTierChangeTime,Metadata
-BlobSchemaField name,Creation-Time,Last-Modified,Content-Length,Content-MD5,BlobType,AccessTier,AccessTierChangeTime,Metadata,AccessTierInferred,Tags
$rule2 = New-AzStorageBlobInventoryPolicyRule -Name test2 -Destination $containerName -Disabled -Format Csv -Schedule Daily -ContainerSchemaField Name,Metadata,PublicAccess,Last-mOdified,LeaseStatus,LeaseState,LeaseDuration,HasImmutabilityPolicy,HasLegalHold -PrefixMatch con1,con2
$rule3 = New-AzStorageBlobInventoryPolicyRule -Name test3 -Destination $containerName -BlobType appendBlob -PrefixMatch abc1,edf1 -Format Csv -Schedule Weekly -BlobSchemaField Name

Expand All @@ -1775,7 +1779,7 @@ function Test-StorageBlobInventory
Assert-AreEqual "Parquet" $policy1.Rules[0].Definition.Format
Assert-AreEqual "Weekly" $policy1.Rules[0].Definition.Schedule
Assert-AreEqual "Blob" $policy1.Rules[0].Definition.ObjectType
Assert-AreEqual 12 $policy1.Rules[0].Definition.SchemaFields.Count
Assert-AreEqual 14 $policy1.Rules[0].Definition.SchemaFields.Count
Assert-AreEqual $true $policy1.Rules[0].Definition.Filters.IncludeSnapshots
Assert-AreEqual $true $policy1.Rules[0].Definition.Filters.IncludeBlobVersions
Assert-AreEqual 2 $policy1.Rules[0].Definition.Filters.BlobTypes.Count
Expand Down Expand Up @@ -1881,7 +1885,7 @@ function Test-StorageBlobInventory
Assert-AreEqual "Parquet" $policy3.Rules[0].Definition.Format
Assert-AreEqual "Weekly" $policy3.Rules[0].Definition.Schedule
Assert-AreEqual "Blob" $policy3.Rules[0].Definition.ObjectType
Assert-AreEqual 12 $policy3.Rules[0].Definition.SchemaFields.Count
Assert-AreEqual 14 $policy3.Rules[0].Definition.SchemaFields.Count
Assert-AreEqual $true $policy3.Rules[0].Definition.Filters.IncludeSnapshots
Assert-AreEqual $true $policy3.Rules[0].Definition.Filters.IncludeBlobVersions
Assert-AreEqual 2 $policy3.Rules[0].Definition.Filters.BlobTypes.Count
Expand Down Expand Up @@ -1981,7 +1985,7 @@ function Test-NewAzureStorageAccountEnableNfsV3
-EnableNfsV3 $true `
-EnableHierarchicalNamespace $true `
-EnableHttpsTrafficOnly $false `
-NetworkRuleSet (@{bypass="Logging,Metrics";defaultAction="allow";virtualNetworkRules=(@{VirtualNetworkResourceId="$vnet1";Action="allow"})})
-NetworkRuleSet (@{bypass="Logging,Metrics";defaultAction="deny";virtualNetworkRules=(@{VirtualNetworkResourceId="$vnet1";Action="allow"})})

Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
Assert-AreEqual $stoname $sto.StorageAccountName;
Expand All @@ -1992,6 +1996,18 @@ function Test-NewAzureStorageAccountEnableNfsV3
Assert-AreEqual $false $sto.EnableHttpsTrafficOnly
Assert-AreEqual $true $sto.EnableNfsV3

# valid create container with NFSv3 properties
$containerName = "container"+ $rgname
$con = New-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -RootSquash RootSquash
Assert-AreEqual $false $con.EnableNfsV3AllSquash
Assert-AreEqual $true $con.EnableNfsV3RootSquash
$con = Update-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -RootSquash NoRootSquash
Assert-AreEqual $false $con.EnableNfsV3AllSquash
Assert-AreEqual $false $con.EnableNfsV3RootSquash
$con = Update-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -RootSquash AllSquash
Assert-AreEqual $true $con.EnableNfsV3AllSquash
Assert-AreEqual $false $con.EnableNfsV3RootSquash

Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ function Test-StorageBlobContainerLegalHold
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
$loc = Get-ProviderLocation ResourceManagement;
$loc = Get-ProviderLocation_Canary ResourceManagement;
$kind = 'StorageV2'
$containerName = "container"+ $rgname

Write-Verbose "RGName: $rgname | Loc: $loc"
New-AzResourceGroup -Name $rgname -Location $loc;

New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind -EnableHierarchicalNamespace $true
$stos = Get-AzStorageAccount -ResourceGroupName $rgname;

New-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName
Expand All @@ -246,7 +246,7 @@ function Test-StorageBlobContainerLegalHold
Assert-AreEqual $false $container.HasImmutabilityPolicy
Assert-AreEqual none $container.PublicAccess

Add-AzRmStorageContainerLegalHold -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -Tag tag1,tag2,tag3
Add-AzRmStorageContainerLegalHold -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -Tag tag1,tag2,tag3 -AllowProtectedAppendWriteAll $true
$container = Get-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName
Assert-AreEqual $containerName $container.Name
Assert-AreEqual 3 $container.LegalHold.Tags.Count
Expand All @@ -259,6 +259,7 @@ function Test-StorageBlobContainerLegalHold
Assert-AreEqual "tag3" $container.LegalHold.Tags[2].Tag
Assert-AreNotEqual $null $container.LegalHold.Tags[2].Timestamp
Assert-AreNotEqual $null $container.LegalHold.Tags[2].ObjectIdentifier
Assert-AreEqual $true $container.LegalHold.ProtectedAppendWritesHistory.AllowProtectedAppendWritesAll

Remove-AzRmStorageContainerLegalHold -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -Tag tag1,tag2
$container = Get-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName
Expand Down Expand Up @@ -308,7 +309,7 @@ function Test-StorageBlobContainerImmutabilityPolicy
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
$loc = Get-ProviderLocation ResourceManagement;
$loc = Get-ProviderLocation_Canary ResourceManagement;
$kind = 'StorageV2'
$containerName = "container"+ $rgname

Expand Down Expand Up @@ -352,12 +353,13 @@ function Test-StorageBlobContainerImmutabilityPolicy
Assert-AreEqual $true $container.ImmutabilityPolicy.AllowProtectedAppendWrites

$immutabilityPeriod =2
Set-AzRmStorageContainerImmutabilityPolicy -inputObject $policy -ImmutabilityPeriod $immutabilityPeriod -AllowProtectedAppendWrite $false
Set-AzRmStorageContainerImmutabilityPolicy -inputObject $policy -ImmutabilityPeriod $immutabilityPeriod -AllowProtectedAppendWrite $false -AllowProtectedAppendWriteAll $true
$policy = Get-AzRmStorageContainerImmutabilityPolicy -ResourceGroupName $rgname -StorageAccountName $stoname -ContainerName $containerName
Assert-AreEqual $immutabilityPeriod $policy.ImmutabilityPeriodSinceCreationInDays
Assert-AreEqual Unlocked $policy.State
Assert-AreNotEqual $null $policy.Etag
Assert-AreEqual $false $policy.AllowProtectedAppendWrites
Assert-AreEqual $true $policy.AllowProtectedAppendWritesAll
$container = Get-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName
Assert-AreEqual $containerName $container.Name
Assert-AreEqual $immutabilityPeriod $container.ImmutabilityPolicy.ImmutabilityPeriodSinceCreationInDays
Expand All @@ -368,6 +370,7 @@ function Test-StorageBlobContainerImmutabilityPolicy
Assert-AreNotEqual $null $container.ImmutabilityPolicy.UpdateHistory[0].Timestamp
Assert-AreNotEqual $null $container.ImmutabilityPolicy.UpdateHistory[0].ObjectIdentifier
Assert-AreEqual $false $container.ImmutabilityPolicy.AllowProtectedAppendWrites
Assert-AreEqual $true $container.ImmutabilityPolicy.AllowProtectedAppendWritesAll

Remove-AzRmStorageContainerImmutabilityPolicy -inputObject $policy
$policy = Get-AzRmStorageContainerImmutabilityPolicy -ResourceGroupName $rgname -StorageAccountName $stoname -ContainerName $containerName
Expand Down
Loading