Skip to content

Commit 6ac886e

Browse files
author
begoldsm
committed
Add Enable-AdlStoreKeyVault cmdlet and help
There was a missing cmdlet to enable the keyvault for an ADLS account. This cmdlet has been added, as well as a simple test for it and an update to our help.
1 parent 4295a5d commit 6ac886e

File tree

10 files changed

+22919
-1118
lines changed

10 files changed

+22919
-1118
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.AdlsTests/TestAdlsAccount.json

Lines changed: 11321 additions & 557 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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.DataLakeStore
19+
{
20+
[Cmdlet(VerbsLifecycle.Enable, "AzureRmDataLakeStoreKeyVault")]
21+
[Alias("Enable-AdlStoreKeyVault")]
22+
public class EnableAzureDataLakeStoreKeyVault : DataLakeStoreCmdletBase
23+
{
24+
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
25+
HelpMessage = "The Data Lake Store account to enable the Key Vault for")]
26+
[ValidateNotNullOrEmpty]
27+
[Alias("AccountName")]
28+
public string Account { get; set; }
29+
30+
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false,
31+
HelpMessage = "Name of resource group associated with the account.")]
32+
[ValidateNotNullOrEmpty]
33+
public string ResourceGroupName { get; set; }
34+
35+
public override void ExecuteCmdlet()
36+
{
37+
DataLakeStoreClient.EnableKeyVault(ResourceGroupName, Account);
38+
}
39+
}
40+
}

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))
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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>]
16+
```
17+
18+
## DESCRIPTION
19+
The **Enable-AzureRmDataLakeStoreKeyVault** cmdlet attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.
20+
21+
## EXAMPLES
22+
23+
### Example 1: Enable the Key Vault for the ContosoADLS account
24+
```
25+
PS C:\>Enable-AzureRmDataLakeStoreKeyVault -Name "ContosoADLS"
26+
```
27+
28+
This command attempts to enable the user managed Key Vault for the Data Lake Store account named ContosoADLS.
29+
30+
## PARAMETERS
31+
32+
### -Account
33+
The Data Lake Store account to enable the user managed Key Vault for
34+
35+
```yaml
36+
Type: String
37+
Parameter Sets: (All)
38+
Aliases: AccountName
39+
40+
Required: True
41+
Position: 0
42+
Default value: None
43+
Accept pipeline input: True (ByPropertyName)
44+
Accept wildcard characters: False
45+
```
46+
47+
### -ResourceGroupName
48+
Name of resource group associated with the account. If not specified will attempt to be discovered.
49+
50+
```yaml
51+
Type: String
52+
Parameter Sets: (All)
53+
Aliases:
54+
55+
Required: False
56+
Position: Named
57+
Default value: None
58+
Accept pipeline input: True (ByPropertyName)
59+
Accept wildcard characters: False
60+
```
61+
62+
### CommonParameters
63+
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).
64+
65+
## INPUTS
66+
67+
### System.String
68+
69+
## OUTPUTS
70+
71+
## NOTES
72+
73+
## RELATED LINKS
74+
75+
[New-AzureRmDataLakeStoreAccount](./New-AzureRmDataLakeStoreAccount.md)
76+
77+
[Set-AzureRmDataLakeStoreAccount](./Set-AzureRmDataLakeStoreAccount.md)
78+

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)