Skip to content

Commit 54327cc

Browse files
authored
[Storage] support create Storage account with RequireInfrastructureEncryption (#12096)
* [Storage] Upgrade to SRP SDK 17.0.0 * [Storage] Support double Encryption
1 parent 0a15e8a commit 54327cc

File tree

15 files changed

+199
-337
lines changed

15 files changed

+199
-337
lines changed

src/ApplicationInsights/ApplicationInsights.Test/ApplicationInsights.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Management.ApplicationInsights" Version="0.3.0-preview" />
15-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
15+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
1616
</ItemGroup>
1717

1818
</Project>

src/EventGrid/EventGrid.Test/EventGrid.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="2.5.0" />
1616
<PackageReference Include="Microsoft.Azure.Management.Relay" Version="2.0.2" />
1717
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="2.1.0" />
18-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
18+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
1919
</ItemGroup>
2020

2121
</Project>

src/OperationalInsights/OperationalInsights.Test/OperationalInsights.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.21.0-preview" />
1515
<PackageReference Include="Microsoft.Azure.OperationalInsights" Version="0.10.0-preview" />
16-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
16+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
1717
</ItemGroup>
1818

1919
</Project>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,21 @@ function Test-GetAzureStorageAccount
156156
# Test
157157
$stoname = 'sto' + $rgname;
158158
$stotype = 'Standard_GRS';
159-
$loc = Get-ProviderLocation ResourceManagement;
159+
$loc = Get-ProviderLocation_Canary ResourceManagement;
160160
$kind = 'StorageV2'
161161

162162
New-AzResourceGroup -Name $rgname -Location $loc;
163163
Write-Output ("Resource Group created")
164164

165-
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype ;
165+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -RequireInfrastructureEncryption;
166166

167167
Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
168168
Assert-AreEqual $stoname $sto.StorageAccountName;
169169
Assert-AreEqual $stotype $sto.Sku.Name;
170170
Assert-AreEqual $loc.ToLower().Replace(" ", "") $sto.Location;
171171
Assert-AreEqual $kind $sto.Kind;
172172
Assert-AreEqual $true $sto.EnableHttpsTrafficOnly;
173+
Assert-AreEqual $true $sto.Encryption.RequireInfrastructureEncryption
173174

174175
$stos = Get-AzStorageAccount -ResourceGroupName $rgname;
175176
Assert-AreEqual $stoname $stos[0].StorageAccountName;

src/Storage/Storage.Management.Test/SessionRecords/Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests/TestGetAzureStorageAccount.json

Lines changed: 128 additions & 308 deletions
Large diffs are not rendered by default.

src/Storage/Storage.Management.Test/Storage.Management.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.0.0" />
1616
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.2.0" />
1717
<PackageReference Include="Azure.Storage.Queues" Version="12.3.0" />
18-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
18+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
1919
</ItemGroup>
2020

2121
</Project>

src/Storage/Storage.Management/Blob/NewAzureStorageContainer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ public override void ExecuteCmdlet()
111111
this.ResourceGroupName,
112112
this.StorageAccountName,
113113
this.Name,
114-
(PublicAccess?)this.publicAccess,
115-
MetadataDictionary);
114+
new BlobContainer(
115+
publicAccess: (PublicAccess?)this.publicAccess,
116+
metadata: MetadataDictionary));
116117

117118
WriteObject(new PSContainer(contaienr));
118119
}

src/Storage/Storage.Management/Blob/UpdateAzureStorageContainer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ public override void ExecuteCmdlet()
138138
this.ResourceGroupName,
139139
this.StorageAccountName,
140140
this.Name,
141-
(PublicAccess?)this.publicAccess,
142-
MetadataDictionary);
141+
new BlobContainer(
142+
publicAccess: (PublicAccess?)this.publicAccess,
143+
metadata: MetadataDictionary));
143144

144145
WriteObject(new PSContainer(container));
145146
}

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 create Storage account with RequireInfrastructureEncryption
22+
- `New-AzStorageAccount`
2123
* Moved the logic of loading Azure.Core to Az.Accounts
2224

2325
## Version 2.1.0

src/Storage/Storage.Management/File/NewAzureStorageShare.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ public override void ExecuteCmdlet()
111111
this.ResourceGroupName,
112112
this.StorageAccountName,
113113
this.Name,
114-
MetadataDictionary,
115-
shareQuota);
114+
new FileShare(
115+
metadata: MetadataDictionary,
116+
shareQuota: shareQuota));
116117

117118
WriteObject(new PSShare(share));
118119
}

src/Storage/Storage.Management/File/UpdateAzureStorageShare.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ public override void ExecuteCmdlet()
151151
this.ResourceGroupName,
152152
this.StorageAccountName,
153153
this.Name,
154-
MetadataDictionary,
155-
shareQuota);
154+
new FileShare(
155+
metadata: MetadataDictionary,
156+
shareQuota: shareQuota));
156157

157158
WriteObject(new PSShare(Share));
158159
}

src/Storage/Storage.Management/Storage.Management.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)</RootNamespace>
1515
</PropertyGroup>
1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
17+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
1818
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.1" />
1919
<PackageReference Include="Microsoft.Azure.Storage.File" Version="11.1.1" />
2020
<PackageReference Include="Microsoft.Azure.Storage.Queue" Version="11.1.1" />

src/Storage/Storage.Management/StorageAccount/NewAzureStorageAccount.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ public bool EnableActiveDirectoryDomainServicesForFile
272272
IgnoreCase = true)]
273273
public string EncryptionKeyTypeForQueue { get; set; }
274274

275+
[Parameter(Mandatory = false, HelpMessage = "The service will apply a secondary layer of encryption with platform managed keys for data at rest.")]
276+
public SwitchParameter RequireInfrastructureEncryption { get; set; }
277+
275278
public override void ExecuteCmdlet()
276279
{
277280
base.ExecuteCmdlet();
@@ -368,18 +371,30 @@ public override void ExecuteCmdlet()
368371
{
369372
createParameters.LargeFileSharesState = LargeFileSharesState.Enabled;
370373
}
371-
if(this.EncryptionKeyTypeForQueue != null || this.EncryptionKeyTypeForTable != null)
374+
if(this.EncryptionKeyTypeForQueue != null || this.EncryptionKeyTypeForTable != null || this.RequireInfrastructureEncryption.IsPresent)
372375
{
373376
createParameters.Encryption = new Encryption();
374377
createParameters.Encryption.KeySource = KeySource.MicrosoftStorage;
375-
createParameters.Encryption.Services = new EncryptionServices();
376-
if (this.EncryptionKeyTypeForQueue != null)
378+
if (this.EncryptionKeyTypeForQueue != null || this.EncryptionKeyTypeForTable != null)
377379
{
378-
createParameters.Encryption.Services.Queue = new EncryptionService(keyType: this.EncryptionKeyTypeForQueue);
380+
createParameters.Encryption.Services = new EncryptionServices();
381+
if (this.EncryptionKeyTypeForQueue != null)
382+
{
383+
createParameters.Encryption.Services.Queue = new EncryptionService(keyType: this.EncryptionKeyTypeForQueue);
384+
}
385+
if (this.EncryptionKeyTypeForTable != null)
386+
{
387+
createParameters.Encryption.Services.Table = new EncryptionService(keyType: this.EncryptionKeyTypeForTable);
388+
}
379389
}
380-
if (this.EncryptionKeyTypeForTable != null)
390+
if (this.RequireInfrastructureEncryption.IsPresent)
381391
{
382-
createParameters.Encryption.Services.Table = new EncryptionService(keyType: this.EncryptionKeyTypeForTable);
392+
createParameters.Encryption.RequireInfrastructureEncryption = true;
393+
if (createParameters.Encryption.Services is null)
394+
{
395+
createParameters.Encryption.Services = new EncryptionServices();
396+
createParameters.Encryption.Services.Blob = new EncryptionService();
397+
}
383398
}
384399
}
385400

src/Storage/Storage.Management/help/New-AzStorageAccount.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
2020
[-Tag <Hashtable>] [-EnableHttpsTrafficOnly <Boolean>] [-AssignIdentity] [-NetworkRuleSet <PSNetworkRuleSet>]
2121
[-EnableHierarchicalNamespace <Boolean>] [-EnableAzureActiveDirectoryDomainServicesForFile <Boolean>]
2222
[-EnableLargeFileShare] [-AsJob] [-EncryptionKeyTypeForTable <String>] [-EncryptionKeyTypeForQueue <String>]
23-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
23+
[-RequireInfrastructureEncryption] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2424
```
2525

2626
### ActiveDirectoryDomainServicesForFile
@@ -32,8 +32,9 @@ New-AzStorageAccount [-ResourceGroupName] <String> [-Name] <String> [-SkuName] <
3232
[-EnableActiveDirectoryDomainServicesForFile <Boolean>] [-ActiveDirectoryDomainName <String>]
3333
[-ActiveDirectoryNetBiosDomainName <String>] [-ActiveDirectoryForestName <String>]
3434
[-ActiveDirectoryDomainGuid <String>] [-ActiveDirectoryDomainSid <String>]
35-
[-ActiveDirectoryAzureStorageSid <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
36-
[<CommonParameters>]
35+
[-ActiveDirectoryAzureStorageSid <String>] [-AsJob] [-EncryptionKeyTypeForTable <String>]
36+
[-EncryptionKeyTypeForQueue <String>] [-RequireInfrastructureEncryption]
37+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
3738
```
3839

3940
## DESCRIPTION
@@ -101,9 +102,9 @@ PS C:\>New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "m
101102

102103
This command creates a Storage account withenable Files Active Directory Domain Service Authentication.
103104

104-
### Example 7: Create a Storage account with Queue and Table Service use account-scoped encryption key.
105+
### Example 7: Create a Storage account with Queue and Table Service use account-scoped encryption key, and Require Infrastructure Encryption.
105106
```powershell
106-
PS C:\>New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "mystorageaccount" -Location "eastus2euap" -SkuName "Standard_LRS" -Kind StorageV2 -EncryptionKeyTypeForTable Account -EncryptionKeyTypeForQueue Account
107+
PS C:\>New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "mystorageaccount" -Location "eastus2euap" -SkuName "Standard_LRS" -Kind StorageV2 -EncryptionKeyTypeForTable Account -EncryptionKeyTypeForQueue Account -RequireInfrastructureEncryption
107108
108109
PS C:\>$account = get-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $accountName
109110
@@ -118,9 +119,13 @@ PS C:\>$account.Encryption.Services.Table
118119
Enabled LastEnabledTime KeyType
119120
------- --------------- -------
120121
True 1/9/2020 6:09:11 AM Account
122+
123+
PS C:\> $account.Encryption.RequireInfrastructureEncryption
124+
True
121125
```
122126

123-
This command creates a Storage account with Queue and Table Service use account-scoped encryption key, so Queue and Table will use same encryption key with Blob and File service. Then get the Storage account properties, and view the encryption keytype of Queue and Table Service.
127+
This command creates a Storage account with Queue and Table Service use account-scoped encryption key and Require Infrastructure Encryption, so Queue and Table will use same encryption key with Blob and File service, and the service will apply a secondary layer of encryption with platform managed keys for data at rest.
128+
Then get the Storage account properties, and view the encryption keytype of Queue and Table Service, and RequireInfrastructureEncryption value.
124129

125130
## PARAMETERS
126131

@@ -477,6 +482,21 @@ Accept pipeline input: False
477482
Accept wildcard characters: False
478483
```
479484
485+
### -RequireInfrastructureEncryption
486+
The service will apply a secondary layer of encryption with platform managed keys for data at rest.
487+
488+
```yaml
489+
Type: System.Management.Automation.SwitchParameter
490+
Parameter Sets: (All)
491+
Aliases:
492+
493+
Required: False
494+
Position: Named
495+
Default value: None
496+
Accept pipeline input: False
497+
Accept wildcard characters: False
498+
```
499+
480500
### -ResourceGroupName
481501
Specifies the name of the resource group in which to add the Storage account.
482502
@@ -549,7 +569,7 @@ Accept wildcard characters: False
549569
```
550570
551571
### CommonParameters
552-
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).
572+
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).
553573
554574
## INPUTS
555575

src/Synapse/Synapse.Test/Synapse.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Management.Synapse" Version="0.1.0-preview.2" />
1515
<PackageReference Include="Microsoft.Azure.Synapse" Version="0.1.0-preview" />
16-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
16+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
1717
</ItemGroup>
1818

1919
</Project>

0 commit comments

Comments
 (0)