Skip to content

Commit cc9a484

Browse files
authored
Merge pull request Azure#4023 from begoldsm/preview
Add Enable-AdlStoreKeyVault cmdlet and help
2 parents ef7d6d7 + 6b4f696 commit cc9a484

File tree

15 files changed

+31579
-2402
lines changed

15 files changed

+31579
-2402
lines changed

src/ResourceManager/DataLakeStore/AzureRM.DataLakeStore.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ CmdletsToExport = 'Get-AzureRmDataLakeStoreTrustedIdProvider',
8282
'Set-AzureRmDataLakeStoreFirewallRule',
8383
'Add-AzureRmDataLakeStoreFirewallRule',
8484
'Add-AzureRmDataLakeStoreItemContent',
85+
'Enable-AzureRmDataLakeStoreKeyVault',
8586
'Export-AzureRmDataLakeStoreItem',
8687
'Get-AzureRmDataLakeStoreChildItem', 'Get-AzureRmDataLakeStoreItem',
8788
'Get-AzureRmDataLakeStoreItemAclEntry',
@@ -112,7 +113,7 @@ AliasesToExport = 'Get-AdlStoreTrustedIdProvider', 'Remove-AdlStoreTrustedIdProv
112113
'Remove-AdlStoreFirewallRule', 'Set-AdlStoreTrustedIdProvider',
113114
'Add-AdlStoreTrustedIdProvider', 'Get-AdlStoreFirewallRule',
114115
'Set-AdlStoreFirewallRule', 'Add-AdlStoreFirewallRule',
115-
'Add-AdlStoreItemContent', 'Export-AdlStoreItem',
116+
'Add-AdlStoreItemContent', 'Export-AdlStoreItem', 'Enable-AdlStoreKeyVault',
116117
'Get-AdlStoreChildItem', 'Get-AdlStoreItem',
117118
'Get-AdlStoreItemAclEntry', 'Get-AdlStoreItemContent',
118119
'Get-AdlStoreItemOwner', 'Get-AdlStoreItemPermission',

src/ResourceManager/DataLakeStore/Commands.DataLakeStore.Test/ScenarioTests/AdlsAliasTests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ function Test-DataLakeStoreAccount
336336
$accountCreated = New-AdlStore -ResourceGroupName $resourceGroupName -Name $secondAccountName -Location $location
337337
Assert-True {$accountCreated.EncryptionConfig -ne $null}
338338
Assert-AreEqual "ServiceManaged" $accountCreated.EncryptionConfig.Type
339+
Assert-AreEqual "Enabled" $accountCreated.EncryptionState
340+
341+
# attempt to enable the key vault, which should throw since it is already enabled
342+
Assert-Throws {Enable-AdlStoreKeyVault -ResourceGroupName $resourceGroupName -Account $secondAccountName}
343+
339344

340345
# Create an account with no encryption explicitly.
341346
$thirdAccountName = Get-DataLakeStoreAccountName

src/ResourceManager/DataLakeStore/Commands.DataLakeStore.Test/ScenarioTests/AdlsTests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ function Test-DataLakeStoreAccount
336336
$accountCreated = New-AzureRMDataLakeStoreAccount -ResourceGroupName $resourceGroupName -Name $secondAccountName -Location $location
337337
Assert-True {$accountCreated.EncryptionConfig -ne $null}
338338
Assert-AreEqual "ServiceManaged" $accountCreated.EncryptionConfig.Type
339+
Assert-AreEqual "Enabled" $accountCreated.EncryptionState
340+
341+
# attempt to enable the key vault, which should throw since it is already enabled
342+
Assert-Throws {Enable-AzureRMDataLakeStoreKeyVault -ResourceGroupName $resourceGroupName -Account $secondAccountName}
343+
339344

340345
# Create an account with no encryption explicitly.
341346
$thirdAccountName = Get-DataLakeStoreAccountName

src/ResourceManager/DataLakeStore/Commands.DataLakeStore.Test/SessionRecords/Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests.AdlsAliasTests/TestAdlsAccount.json

Lines changed: 11452 additions & 556 deletions
Large diffs are not rendered by default.

src/ResourceManager/DataLakeStore/Commands.DataLakeStore.Test/SessionRecords/Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests.AdlsAliasTests/TestAdlsFileSystem.json

Lines changed: 4339 additions & 643 deletions
Large diffs are not rendered by default.

src/ResourceManager/DataLakeStore/Commands.DataLakeStore.Test/SessionRecords/Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests.AdlsTests/TestAdlsAccount.json

Lines changed: 11321 additions & 557 deletions
Large diffs are not rendered by default.

src/ResourceManager/DataLakeStore/Commands.DataLakeStore.Test/SessionRecords/Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests.AdlsTests/TestAdlsFileSystem.json

Lines changed: 4271 additions & 641 deletions
Large diffs are not rendered by default.

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/Commands.DataLakeStore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
107107
</ItemGroup>
108108
<ItemGroup>
109+
<Compile Include="Commands\EnableAzureRmDataLakeStoreKeyVault.cs" />
109110
<Compile Include="Commands\GetAzureRmDataLakeStoreTrustedIdProvider.cs" />
110111
<Compile Include="Commands\RemoveAzureRmDataLakeStoreTrustedIdProvider.cs" />
111112
<Compile Include="Commands\RemoveAzureRmDataLakeStoreFirewallRule.cs" />
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.DataLakeStore.Models;
16+
using Microsoft.Azure.Commands.DataLakeStore.Properties;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.DataLakeStore
20+
{
21+
[Cmdlet(VerbsLifecycle.Enable, "AzureRmDataLakeStoreKeyVault", SupportsShouldProcess = true)]
22+
[Alias("Enable-AdlStoreKeyVault")]
23+
public class EnableAzureDataLakeStoreKeyVault : DataLakeStoreCmdletBase
24+
{
25+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
26+
HelpMessage = "The Data Lake Store account to enable the Key Vault for")]
27+
[ValidateNotNullOrEmpty]
28+
[Alias("AccountName","Name")]
29+
public string Account { get; set; }
30+
31+
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false,
32+
HelpMessage = "Name of resource group associated with the account.")]
33+
[ValidateNotNullOrEmpty]
34+
public string ResourceGroupName { get; set; }
35+
36+
public override void ExecuteCmdlet()
37+
{
38+
ConfirmAction(
39+
string.Format(Resources.EnableKeyVault, Account),
40+
Account,
41+
() => DataLakeStoreClient.EnableKeyVault(ResourceGroupName, Account));
42+
}
43+
}
44+
}

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/Models/DataLakeStoreClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ public DataLakeStoreAccount GetAccount(string resourceGroupName, string accountN
192192

193193
return _client.Account.Get(resourceGroupName, accountName);
194194
}
195+
196+
public void EnableKeyVault(string resourceGroupName, string accountName)
197+
{
198+
if (string.IsNullOrEmpty(resourceGroupName))
199+
{
200+
resourceGroupName = GetResourceGroupByAccount(accountName);
201+
}
202+
203+
_client.Account.EnableKeyVault(resourceGroupName, accountName);
204+
}
205+
195206
public FirewallRule AddOrUpdateFirewallRule(string resourceGroupName, string accountName, string ruleName, string startIp, string endIp, Cmdlet runningCommand)
196207
{
197208
if (string.IsNullOrEmpty(resourceGroupName))

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
<data name="DownloadFileDataMessage" xml:space="preserve">
142142
<value>Download file data</value>
143143
</data>
144+
<data name="EnableKeyVault" xml:space="preserve">
145+
<value>Enabling user supplied KeyVault to the Data Lake Store Account: '{0}' ...</value>
146+
</data>
144147
<data name="FailedToDiscoverResourceGroup" xml:space="preserve">
145148
<value>Could not find account: '{0}' in any resource group in the currently selected subscription: {1}. Please ensure this account exists and that the current user has access to it.</value>
146149
</data>

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/help/AzureRM.DataLakeStore.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Adds content to an item in a Data Lake Store.
2020
### [Add-AzureRmDataLakeStoreTrustedIdProvider](Add-AzureRmDataLakeStoreTrustedIdProvider.md)
2121
Adds a trusted identity provider to the specified Data Lake Store account.
2222

23+
### [Enable-AzureRmDataLakeStoreKeyVault](Enable-AzureRmDataLakeStoreKeyVault.md)
24+
Attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.
25+
2326
### [Export-AzureRmDataLakeStoreItem](Export-AzureRmDataLakeStoreItem.md)
2427
Downloads a file from Data Lake Store.
2528

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
external help file: Microsoft.Azure.Commands.DataLakeStore.dll-Help.xml
3+
online version:
4+
schema: 2.0.0
5+
---
6+
7+
# Enable-AzureRmDataLakeStoreKeyVault
8+
9+
## SYNOPSIS
10+
Attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.
11+
12+
## SYNTAX
13+
14+
```
15+
Enable-AzureRmDataLakeStoreKeyVault [-Account] <String> [-ResourceGroupName <String>] [-WhatIf] [-Confirm]
16+
[<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
The **Enable-AzureRmDataLakeStoreKeyVault** cmdlet attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.
21+
22+
## EXAMPLES
23+
24+
### Example 1: Enable the Key Vault for the ContosoADLS account
25+
```
26+
PS C:\>Enable-AzureRmDataLakeStoreKeyVault -Name "ContosoADLS"
27+
```
28+
29+
This command attempts to enable the user managed Key Vault for the Data Lake Store account named ContosoADLS.
30+
31+
## PARAMETERS
32+
33+
### -Account
34+
The Data Lake Store account to enable the user managed Key Vault for
35+
36+
```yaml
37+
Type: String
38+
Parameter Sets: (All)
39+
Aliases: AccountName, Name
40+
41+
Required: True
42+
Position: 0
43+
Default value: None
44+
Accept pipeline input: True (ByPropertyName)
45+
Accept wildcard characters: False
46+
```
47+
48+
### -ResourceGroupName
49+
Name of resource group associated with the account. If not specified will attempt to be discovered.
50+
51+
```yaml
52+
Type: String
53+
Parameter Sets: (All)
54+
Aliases:
55+
56+
Required: False
57+
Position: Named
58+
Default value: None
59+
Accept pipeline input: True (ByPropertyName)
60+
Accept wildcard characters: False
61+
```
62+
63+
### -Confirm
64+
Prompts you for confirmation before running the cmdlet.
65+
66+
```yaml
67+
Type: SwitchParameter
68+
Parameter Sets: (All)
69+
Aliases: cf
70+
71+
Required: False
72+
Position: Named
73+
Default value: None
74+
Accept pipeline input: False
75+
Accept wildcard characters: False
76+
```
77+
78+
### -WhatIf
79+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
80+
81+
```yaml
82+
Type: SwitchParameter
83+
Parameter Sets: (All)
84+
Aliases: wi
85+
86+
Required: False
87+
Position: Named
88+
Default value: None
89+
Accept pipeline input: False
90+
Accept wildcard characters: False
91+
```
92+
93+
### CommonParameters
94+
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).
95+
96+
## INPUTS
97+
98+
### System.String
99+
100+
## OUTPUTS
101+
102+
## NOTES
103+
104+
## RELATED LINKS
105+
106+
[New-AzureRmDataLakeStoreAccount](./New-AzureRmDataLakeStoreAccount.md)
107+
108+
[Set-AzureRmDataLakeStoreAccount](./Set-AzureRmDataLakeStoreAccount.md)
109+

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/help/Get-AzureRmDataLakeStoreItemContent.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePa
2121

2222
### Preview file rows from the head of the file
2323
```
24-
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [-Head <Int32>]
24+
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [[-Head] <Int32>]
2525
[[-Encoding] <FileSystemCmdletProviderEncoding>] [-WhatIf] [-Confirm] [<CommonParameters>]
2626
```
2727

2828
### Preview file rows from the tail of the file
2929
```
30-
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [-Tail <Int32>]
30+
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [[-Tail] <Int32>]
3131
[[-Encoding] <FileSystemCmdletProviderEncoding>] [-WhatIf] [-Confirm] [<CommonParameters>]
3232
```
3333

@@ -118,7 +118,7 @@ Parameter Sets: Preview file rows from the head of the file
118118
Aliases:
119119

120120
Required: False
121-
Position: Named
121+
Position: 2
122122
Default value: None
123123
Accept pipeline input: True (ByPropertyName)
124124
Accept wildcard characters: False
@@ -176,7 +176,7 @@ Parameter Sets: Preview file rows from the tail of the file
176176
Aliases:
177177

178178
Required: False
179-
Position: Named
179+
Position: 2
180180
Default value: None
181181
Accept pipeline input: True (ByPropertyName)
182182
Accept wildcard characters: False

0 commit comments

Comments
 (0)