Skip to content

Commit 517b636

Browse files
authored
[Storage] Support MaxPageSize, Include, and Filter for listing encryption scopes (#20169)
* list encryption scope * update swagger urls * update list encryption scopes, examples, and changelog * add example issues * update per comments
1 parent c30e70e commit 517b636

File tree

5 files changed

+874
-371
lines changed

5 files changed

+874
-371
lines changed

src/Storage/Storage.Management.Test/ScenarioTests/StorageBlobTests.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ function Test-StorageBlobContainerEncryptionScope
165165
$containerName2 = "container2"+ $rgname
166166
$scopeName = "testscope"
167167
$scopeName2 = "testscope2"
168+
$scopeName3 = "filtertestscope3"
168169

169170
Write-Verbose "RGName: $rgname | Loc: $loc"
170171
New-AzResourceGroup -Name $rgname -Location $loc;
@@ -190,8 +191,20 @@ function Test-StorageBlobContainerEncryptionScope
190191

191192
#List Scope
192193
New-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName2 -StorageEncryption
194+
New-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName3 -StorageEncryption
195+
Update-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName3 -State Disabled
193196
$scopes = Get-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname
197+
Assert-AreEqual 3 $scopes.Count
198+
$scopes = Get-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -MaxPageSize 1 -Include Disabled
199+
Assert-AreEqual 1 $scopes.Count
200+
Assert-AreEqual "Disabled" $scopes[0].State
201+
$scopes = Get-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -Include All -Filter "startswith(name, filter)"
202+
Assert-AreEqual 1 $scopes.Count
203+
Assert-AreEqual $scopeName3 $scopes[0].Name
204+
$scopes = Get-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -Include Enabled
194205
Assert-AreEqual 2 $scopes.Count
206+
Assert-AreEqual "Enabled" $scopes[0].State
207+
Assert-AreEqual "Enabled" $scopes[1].State
195208

196209
#create container
197210
New-AzRmStorageContainer -ResourceGroupName $rgname -StorageAccountName $stoname -Name $containerName -DefaultEncryptionScope $scopename -PreventEncryptionScopeOverride $true

src/Storage/Storage.Management.Test/SessionRecords/Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageBlobTests/TestStorageBlobContainerEncryptionScope.json

Lines changed: 757 additions & 367 deletions
Large diffs are not rendered by default.

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Supported MaxPageSize, Include, and Filter parameters for listing encryption scopes
22+
- `Get-AzStorageEncryptionScope`
2123
* Supported excludePrefix, includeDeleted, and many new schema fields in Blob Inventory
2224
- `New-AzStorageBlobInventoryPolicyRule`
2325

src/Storage/Storage.Management/StorageAccount/GetAzureStorageEncryptionScope.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,24 @@ public class GetAzureStorageEncryptionScopeCommand : StorageFileBaseCmdlet
6868
[ValidateNotNullOrEmpty]
6969
public string EncryptionScopeName { get; set; }
7070

71+
[Parameter(Mandatory = false,
72+
HelpMessage = "The maximum number of encryption scopes that will be included in the list response")]
73+
[ValidateNotNullOrEmpty]
74+
public int? MaxPageSize { get; set; }
75+
76+
[Parameter(Mandatory = false,
77+
HelpMessage = "The filter of encryption scope name. When specified, only encryption scope names starting with the filter will be listed. The filter must be in format: startswith(name, <prefix>)")]
78+
[ValidateNotNullOrEmpty]
79+
public string Filter { get; set; }
80+
81+
[Parameter(Mandatory = false,
82+
HelpMessage = "Optional, when specified, will list encryption scopes with the specific state. Defaults to All.")]
83+
[ValidateSet(ListEncryptionScopesInclude.All,
84+
ListEncryptionScopesInclude.Enabled,
85+
ListEncryptionScopesInclude.Disabled)]
86+
[ValidateNotNullOrEmpty]
87+
public string Include { get; set; }
88+
7189
public override void ExecuteCmdlet()
7290
{
7391
base.ExecuteCmdlet();
@@ -87,7 +105,7 @@ public override void ExecuteCmdlet()
87105
{
88106
IPage<EncryptionScope> scopes = this.StorageClient.EncryptionScopes.List(
89107
this.ResourceGroupName,
90-
this.StorageAccountName);
108+
this.StorageAccountName, this.MaxPageSize, this.Filter, this.Include);
91109
WriteEncryptionScopeList(scopes);
92110

93111
while (scopes.NextPageLink != null)

src/Storage/Storage.Management/help/Get-AzStorageEncryptionScope.md

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ Get or list encryption scopes from a Storage account.
1515
### AccountName (Default)
1616
```
1717
Get-AzStorageEncryptionScope [-ResourceGroupName] <String> [-StorageAccountName] <String>
18-
[-EncryptionScopeName <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
18+
[-EncryptionScopeName <String>] [-MaxPageSize <Int32>] [-Filter <String>] [-Include <String>]
19+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1920
```
2021

2122
### AccountObject
2223
```
2324
Get-AzStorageEncryptionScope -StorageAccount <PSStorageAccount> [-EncryptionScopeName <String>]
24-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
25+
[-MaxPageSize <Int32>] [-Filter <String>] [-Include <String>] [-DefaultProfile <IAzureContextContainer>]
26+
[<CommonParameters>]
2527
```
2628

2729
## DESCRIPTION
@@ -60,6 +62,38 @@ scope2 Enabled Microsoft.Storage
6062

6163
This command lists all encryption scopes of a Storage account.
6264

65+
### Example 3: List all enabled encryption scopes of a Storage account with a max page size of 10 for each request
66+
```powershell
67+
Get-AzStorageEncryptionScope -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -MaxPageSize 10 -Include Enabled
68+
```
69+
70+
```output
71+
ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount
72+
73+
Name State Source KeyVaultKeyUri
74+
---- ----- ------ --------------
75+
scope1 Enabled Microsoft.Keyvault https://keyvalutname.vault.azure.net:443/keys/keyname
76+
scope2 Enabled Microsoft.Storage
77+
```
78+
This command lists all enabled encryption scopes of a Storage account, with a max page size of 10 encryption scopes included in each list response.
79+
If there are more than 10 encryption scopes to be listed, the command will still list all the encryption scopes, but with multiple requests sent and responses received.
80+
81+
### Example 4: List all disabled encryption scopes with names starting with "test" of a Storage account
82+
```powershell
83+
Get-AzStorageEncryptionScope -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -Include Disabled -Filter "startswith(name, test)"
84+
```
85+
86+
```output
87+
ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount
88+
89+
Name State Source KeyVaultKeyUri
90+
---- ----- ------ --------------
91+
testscope1 Disabled Microsoft.Keyvault https://keyvalutname.vault.azure.net:443/keys/keyname
92+
testscope2 Disabled Microsoft.Storage
93+
```
94+
This command lists all disabled encryption scopes with names starting with "test" of a Storage account.
95+
The parameter "Filter" specifies the prefix of the encryption scopes listed, and it should be in format of “startswith(name, {prefixValue})”.
96+
6397
## PARAMETERS
6498

6599
### -DefaultProfile
@@ -92,6 +126,52 @@ Accept pipeline input: False
92126
Accept wildcard characters: False
93127
```
94128
129+
### -Filter
130+
The filter of encryption scope name. When specified, only encryption scope names starting with the filter will be listed.
131+
132+
```yaml
133+
Type: System.String
134+
Parameter Sets: (All)
135+
Aliases:
136+
137+
Required: False
138+
Position: Named
139+
Default value: None
140+
Accept pipeline input: False
141+
Accept wildcard characters: False
142+
```
143+
144+
### -Include
145+
The filter of encryption scope name. When specified, only encryption scope names starting with the filter will be listed.
146+
147+
```yaml
148+
Type: System.String
149+
Parameter Sets: (All)
150+
Aliases:
151+
Accepted values: All, Enabled, Disabled
152+
153+
Required: False
154+
Position: Named
155+
Default value: None
156+
Accept pipeline input: False
157+
Accept wildcard characters: False
158+
```
159+
160+
### -MaxPageSize
161+
The maximum number of encryption scopes that will be included in the list response
162+
163+
```yaml
164+
Type: System.Nullable`1[System.Int32]
165+
Parameter Sets: (All)
166+
Aliases:
167+
168+
Required: False
169+
Position: Named
170+
Default value: None
171+
Accept pipeline input: False
172+
Accept wildcard characters: False
173+
```
174+
95175
### -ResourceGroupName
96176
Resource Group Name.
97177
@@ -138,7 +218,7 @@ Accept wildcard characters: False
138218
```
139219
140220
### CommonParameters
141-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
221+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
142222
143223
## INPUTS
144224

0 commit comments

Comments
 (0)