Skip to content

Add Enable-AdlStoreKeyVault cmdlet and help #4023

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 6 commits into from
Jun 1, 2017
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
3 changes: 2 additions & 1 deletion src/ResourceManager/DataLakeStore/AzureRM.DataLakeStore.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ CmdletsToExport = 'Get-AzureRmDataLakeStoreTrustedIdProvider',
'Set-AzureRmDataLakeStoreFirewallRule',
'Add-AzureRmDataLakeStoreFirewallRule',
'Add-AzureRmDataLakeStoreItemContent',
'Enable-AzureRmDataLakeStoreKeyVault',
'Export-AzureRmDataLakeStoreItem',
'Get-AzureRmDataLakeStoreChildItem', 'Get-AzureRmDataLakeStoreItem',
'Get-AzureRmDataLakeStoreItemAclEntry',
Expand Down Expand Up @@ -112,7 +113,7 @@ AliasesToExport = 'Get-AdlStoreTrustedIdProvider', 'Remove-AdlStoreTrustedIdProv
'Remove-AdlStoreFirewallRule', 'Set-AdlStoreTrustedIdProvider',
'Add-AdlStoreTrustedIdProvider', 'Get-AdlStoreFirewallRule',
'Set-AdlStoreFirewallRule', 'Add-AdlStoreFirewallRule',
'Add-AdlStoreItemContent', 'Export-AdlStoreItem',
'Add-AdlStoreItemContent', 'Export-AdlStoreItem', 'Enable-AdlStoreKeyVault',
'Get-AdlStoreChildItem', 'Get-AdlStoreItem',
'Get-AdlStoreItemAclEntry', 'Get-AdlStoreItemContent',
'Get-AdlStoreItemOwner', 'Get-AdlStoreItemPermission',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ function Test-DataLakeStoreAccount
$accountCreated = New-AdlStore -ResourceGroupName $resourceGroupName -Name $secondAccountName -Location $location
Assert-True {$accountCreated.EncryptionConfig -ne $null}
Assert-AreEqual "ServiceManaged" $accountCreated.EncryptionConfig.Type
Assert-AreEqual "Enabled" $accountCreated.EncryptionState

# attempt to enable the key vault, which should throw since it is already enabled
Assert-Throws {Enable-AdlStoreKeyVault -ResourceGroupName $resourceGroupName -Account $secondAccountName}


# Create an account with no encryption explicitly.
$thirdAccountName = Get-DataLakeStoreAccountName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ function Test-DataLakeStoreAccount
$accountCreated = New-AzureRMDataLakeStoreAccount -ResourceGroupName $resourceGroupName -Name $secondAccountName -Location $location
Assert-True {$accountCreated.EncryptionConfig -ne $null}
Assert-AreEqual "ServiceManaged" $accountCreated.EncryptionConfig.Type
Assert-AreEqual "Enabled" $accountCreated.EncryptionState

# attempt to enable the key vault, which should throw since it is already enabled
Assert-Throws {Enable-AzureRMDataLakeStoreKeyVault -ResourceGroupName $resourceGroupName -Account $secondAccountName}


# Create an account with no encryption explicitly.
$thirdAccountName = Get-DataLakeStoreAccountName
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\EnableAzureRmDataLakeStoreKeyVault.cs" />
<Compile Include="Commands\GetAzureRmDataLakeStoreTrustedIdProvider.cs" />
<Compile Include="Commands\RemoveAzureRmDataLakeStoreTrustedIdProvider.cs" />
<Compile Include="Commands\RemoveAzureRmDataLakeStoreFirewallRule.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.DataLakeStore.Models;
using Microsoft.Azure.Commands.DataLakeStore.Properties;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.DataLakeStore
{
[Cmdlet(VerbsLifecycle.Enable, "AzureRmDataLakeStoreKeyVault", SupportsShouldProcess = true)]
[Alias("Enable-AdlStoreKeyVault")]
public class EnableAzureDataLakeStoreKeyVault : DataLakeStoreCmdletBase
{
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
HelpMessage = "The Data Lake Store account to enable the Key Vault for")]
[ValidateNotNullOrEmpty]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alias("Name")]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a break from the pattern that we have been using for other ADLA and ADLS commands. Is it expected that we should include a "Name" alias as well now? I am ok with adding it here right now, just want to make sure that I know it should be added to the other cmdlets in the future as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markcowl just spoke with PM. We would rather hold off on this to make sure it makes sense for all of our cmdlets that have an Account/AccountName parameter, since we want to ensure a consistent parameter naming across all the ADL cmdlets for users. Given this, are you ok with accepting this PR without the Alias change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@begoldsm This is just about piping scenarios. If the intention is to allow piping from generic cmdlets, then this needs to be 'Name' to allow piping by PropertyName. Otherwise, not sure why you would have piping ByPropertyName for the 'resourcegroupname' parameter

[Alias("AccountName","Name")]
public string Account { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false,
HelpMessage = "Name of resource group associated with the account.")]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

public override void ExecuteCmdlet()
{
ConfirmAction(
string.Format(Resources.EnableKeyVault, Account),
Account,
() => DataLakeStoreClient.EnableKeyVault(ResourceGroupName, Account));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ public DataLakeStoreAccount GetAccount(string resourceGroupName, string accountN

return _client.Account.Get(resourceGroupName, accountName);
}

public void EnableKeyVault(string resourceGroupName, string accountName)
{
if (string.IsNullOrEmpty(resourceGroupName))
{
resourceGroupName = GetResourceGroupByAccount(accountName);
}

_client.Account.EnableKeyVault(resourceGroupName, accountName);
}

public FirewallRule AddOrUpdateFirewallRule(string resourceGroupName, string accountName, string ruleName, string startIp, string endIp, Cmdlet runningCommand)
{
if (string.IsNullOrEmpty(resourceGroupName))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<data name="DownloadFileDataMessage" xml:space="preserve">
<value>Download file data</value>
</data>
<data name="EnableKeyVault" xml:space="preserve">
<value>Enabling user supplied KeyVault to the Data Lake Store Account: '{0}' ...</value>
</data>
<data name="FailedToDiscoverResourceGroup" xml:space="preserve">
<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>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Adds content to an item in a Data Lake Store.
### [Add-AzureRmDataLakeStoreTrustedIdProvider](Add-AzureRmDataLakeStoreTrustedIdProvider.md)
Adds a trusted identity provider to the specified Data Lake Store account.

### [Enable-AzureRmDataLakeStoreKeyVault](Enable-AzureRmDataLakeStoreKeyVault.md)
Attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.

### [Export-AzureRmDataLakeStoreItem](Export-AzureRmDataLakeStoreItem.md)
Downloads a file from Data Lake Store.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
external help file: Microsoft.Azure.Commands.DataLakeStore.dll-Help.xml
online version:
schema: 2.0.0
---

# Enable-AzureRmDataLakeStoreKeyVault

## SYNOPSIS
Attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.

## SYNTAX

```
Enable-AzureRmDataLakeStoreKeyVault [-Account] <String> [-ResourceGroupName <String>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
The **Enable-AzureRmDataLakeStoreKeyVault** cmdlet attempts to enable a user managed Key Vault for encryption of the specified Data Lake Store account.

## EXAMPLES

### Example 1: Enable the Key Vault for the ContosoADLS account
```
PS C:\>Enable-AzureRmDataLakeStoreKeyVault -Name "ContosoADLS"
```

This command attempts to enable the user managed Key Vault for the Data Lake Store account named ContosoADLS.

## PARAMETERS

### -Account
The Data Lake Store account to enable the user managed Key Vault for

```yaml
Type: String
Parameter Sets: (All)
Aliases: AccountName, Name

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ResourceGroupName
Name of resource group associated with the account. If not specified will attempt to be discovered.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
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).

## INPUTS

### System.String

## OUTPUTS

## NOTES

## RELATED LINKS

[New-AzureRmDataLakeStoreAccount](./New-AzureRmDataLakeStoreAccount.md)

[Set-AzureRmDataLakeStoreAccount](./Set-AzureRmDataLakeStoreAccount.md)

Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePa

### Preview file rows from the head of the file
```
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [-Head <Int32>]
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [[-Head] <Int32>]
[[-Encoding] <FileSystemCmdletProviderEncoding>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### Preview file rows from the tail of the file
```
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [-Tail <Int32>]
Get-AzureRmDataLakeStoreItemContent [-Account] <String> [-Path] <DataLakeStorePathInstance> [[-Tail] <Int32>]
[[-Encoding] <FileSystemCmdletProviderEncoding>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

Expand Down Expand Up @@ -118,7 +118,7 @@ Parameter Sets: Preview file rows from the head of the file
Aliases:

Required: False
Position: Named
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Expand Down Expand Up @@ -176,7 +176,7 @@ Parameter Sets: Preview file rows from the tail of the file
Aliases:

Required: False
Position: Named
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Expand Down