Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.17.0" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.15.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.15.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.15.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
-->
## Upcoming Release
* Updated Azure.Core to 1.34.0.
* Added support for encryption context
- `New-AzDataLakeGen2Item`


## Version 5.9.0
* Supported OAuth authentication on File service cmdlets
Expand Down
33 changes: 30 additions & 3 deletions src/Storage/Storage.Management/help/New-AzDataLakeGen2Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Create a file or directory in a filesystem.
### File (Default)
```
New-AzDataLakeGen2Item [-FileSystem] <String> [-Path] <String> -Source <String> [-Umask <String>]
[-Permission <String>] [-Property <Hashtable>] [-Metadata <Hashtable>] [-Force] [-AsJob]
[-Context <IStorageContext>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-Permission <String>] [-EncryptionContext <String>] [-Property <Hashtable>] [-Metadata <Hashtable>] [-Force]
[-AsJob] [-Context <IStorageContext>] [-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### Directory
Expand Down Expand Up @@ -66,6 +66,18 @@ dir1/dir2/file1 False 14400000 2020-03-23 09:19:13Z rw-r-----

This command creates(upload) a data lake file from a local source file, and the cmdlet runs in background.

### Example 3: Create(upload) a data lake file from a local source file and set its encryption context
```powershell
$file = New-AzDataLakeGen2Item -FileSystem "testfilesystem" -Path "dir1/dir2/file1" -Source "c:\sourcefile.txt" -EncryptionContext "encryptioncontext"
$file.Properties.EncryptionContext
```

```output
encryptioncontext
```

This command creates(upload) a data lake file from a local source file and sets its encryption context value to "encryptioncontext".

## PARAMETERS

### -AsJob
Expand Down Expand Up @@ -143,6 +155,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -EncryptionContext
Encryption context of the file. Encryption context is metadata that is not encrypted when stored on the file. The primary application of this field is to store non-encrypted data that can be used to derive the customer-provided key for a file. Not applicable for directories.

```yaml
Type: System.String
Parameter Sets: File
Aliases:

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

### -FileSystem
FileSystem name

Expand Down
16 changes: 12 additions & 4 deletions src/Storage/Storage/DatalakeGen2/Cmdlet/NewAzDataLakeGen2Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public string Source
[ValidatePattern("([r-][w-][x-]){2}([r-][w-][xtT-])")]
public string Permission { get; set; }

[Parameter(Mandatory = false,
HelpMessage = "Encryption context of the file. Encryption context is metadata that is not encrypted when stored on the file. The primary application of this field is to store non-encrypted data that can be used to derive the customer-provided key for a file. Not applicable for directories.",
ParameterSetName = FileParameterSet)]
public string EncryptionContext { get; set; }

[Parameter(HelpMessage = "Specifies properties for the created directory or file. "+
"The supported properties for file are: CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ContentMD5, ContentType." +
Expand Down Expand Up @@ -213,9 +217,12 @@ public override void ExecuteCmdlet()
DataLakeFileClient fileClient = fileSystem.GetFileClient(this.Path);
if (ShouldProcess(GetDataLakeItemUriWithoutSas(fileClient), "Create File: "))
{
// Use SDK to upload directly when use SAS credential, and need set permission, since set permission after upload will fail with SAS
if (Channel.StorageContext.StorageAccount != null && Channel.StorageContext.StorageAccount.Credentials != null &&
Channel.StorageContext.StorageAccount.Credentials.IsSAS && (!string.IsNullOrEmpty(this.Permission) || !string.IsNullOrEmpty(this.Umask)))
// Use SDK to upload directly when
// 1. use SAS credential, and need set permission, since set permission after upload will fail with SAS, or
// 2. file encryption context is set by user
if ((Channel.StorageContext.StorageAccount != null && Channel.StorageContext.StorageAccount.Credentials != null &&
Channel.StorageContext.StorageAccount.Credentials.IsSAS && (!string.IsNullOrEmpty(this.Permission) || !string.IsNullOrEmpty(this.Umask))) ||
this.EncryptionContext != null)
{
Func<long, Task> taskGenerator = (taskId) => UploadDataLakeFile(taskId, fileClient, ResolvedFileName);
RunTask(taskGenerator);
Expand Down Expand Up @@ -271,7 +278,8 @@ await fileClient.UploadAsync(ResolvedFileName,
Permissions = this.Permission,
Umask = this.Umask != null ? DataLakeModels.PathPermissions.ParseSymbolicPermissions(this.Umask).ToOctalPermissions() : null,
ProgressHandler = progressHandler,
HttpHeaders = pathHttpHeaders
HttpHeaders = pathHttpHeaders,
EncryptionContext = this.EncryptionContext
},
this.CmdletCancellationToken).ConfigureAwait(false);

Expand Down
8 changes: 4 additions & 4 deletions src/Storage/Storage/Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.8.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.17.0" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.15.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.15.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.15.0" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Include="System.Security.Permissions" Version="4.7.0" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.2.2" />
Expand Down