Skip to content

Commit 1059ac4

Browse files
authored
Merge pull request #7291 from wastoresh/fixmetadata
[Storage] Fix copy blob/file won't overwrite metadata issue and update help
2 parents 16020ad + df595e4 commit 1059ac4

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

src/Storage/Commands.Storage/Blob/Cmdlet/StartAzureStorageBlobCopy.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ private async Task StartCopyFromUri(long taskId, IStorageBlobManagement destChan
567567
if (!destExist || this.ConfirmOverwrite(srcUri.AbsoluteUri.ToString(), destBlob.Uri.ToString()))
568568
{
569569
string copyId;
570+
571+
//Clean the Metadata of the destination Blob object, or the source metadata won't overwirte the dest blob metadata. See https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob
572+
destBlob.Metadata.Clear();
573+
570574
if (pageBlobTier == null)
571575
{
572576
copyId = await destChannel.StartCopyAsync(destBlob, srcUri, null, null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken).ConfigureAwait(false);

src/Storage/Commands.Storage/ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21-
21+
* Fix Copy Blob/File won't copy metadata when destination has metadata issue
22+
- Start-AzureStorageBlobCopy
23+
- Start-AzureStorageFileCopy
24+
2225
## Version 4.6.0
2326
* Upgrade to Azure Storage Client Library 9.3.0 and Azure Storage DataMovement Library 0.8.1
2427
* Support create Storage Context with OAuth.

src/Storage/Commands.Storage/File/Cmdlet/StartAzureStorageFileCopy.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ private async Task StartAsyncCopy(long taskId, CloudFile destFile, Func<bool> ch
366366
try
367367
{
368368
await destFile.FetchAttributesAsync(null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken).ConfigureAwait(false);
369+
370+
//Clean the Metadata of the destination file object, or the source metadata won't overwirte the dest file metadata. See https://docs.microsoft.com/en-us/rest/api/storageservices/copy-file
371+
destFile.Metadata.Clear();
369372
}
370373
catch (StorageException ex)
371374
{

src/Storage/Commands.Storage/help/Get-AzureStorageContainer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Accept wildcard characters: False
8787
### -Context
8888
Specifies the storage context.
8989
To create it, you can use the New-AzureStorageContext cmdlet.
90-
The cmdlet will fail when you use a storage context created from SAS Token because the cmdlet will query for container permissions which require Storage account key permission.
90+
The container permissions won't be retrieved when you use a storage context created from SAS Token, because query container permissions requires Storage account key permission.
9191
9292
```yaml
9393
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext

src/Storage/Commands.Storage/help/Set-AzureStorageBlobContent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ Accept wildcard characters: False
223223
### -Context
224224
Specifies an Azure storage context.
225225
To obtain a storage context, use the New-AzureStorageContext cmdlet.
226+
To use a storage context created from a SAS Token without read permission, need add -Force parameter to skip check blob existance.
226227
227228
```yaml
228229
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext

0 commit comments

Comments
 (0)