Skip to content

[Storage] Fix oauthCopySameAccount #15152

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 1 commit into from
May 31, 2021
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
1 change: 1 addition & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- `Update-AzRmStorageShare`
* Supported enable Smb Multichannel on File service
- `Update-AzStorageFileServiceProperty`
* Fixed copy inside same account issue by access source with anynymous credentail, when copy Blob inside same account with Oauth credentail

## Version 3.7.0
* Supported file share snapshot
Expand Down
30 changes: 28 additions & 2 deletions src/Storage/Storage/Blob/Cmdlet/StartAzureStorageBlobCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,20 @@ private async Task StartCopyFromBlob(long taskId, IStorageBlobManagement destCha
{
try
{
await StartCopyFromUri(taskId, destChannel, srcBlob.GenerateUriWithCredentials(), destBlob).ConfigureAwait(false);
Uri srcBlobUriWithCredentail = null;
if (Channel!=null && destChannel != null &&
Channel.StorageContext!= null && destChannel.StorageContext != null
&& Channel.StorageContext.StorageAccountName == destChannel.StorageContext.StorageAccountName
&& Channel.StorageContext.StorageAccount.Credentials.IsToken)
{
// if inside same account, source blob can be anonumous
srcBlobUriWithCredentail = srcBlob.SnapshotQualifiedUri;
}
else
{
srcBlobUriWithCredentail = srcBlob.GenerateUriWithCredentials();
}
await StartCopyFromUri(taskId, destChannel, srcBlobUriWithCredentail, destBlob).ConfigureAwait(false);
}
catch (StorageException ex)
{
Expand All @@ -648,7 +661,20 @@ private async Task StartCopyFromBlob(long taskId, IStorageBlobManagement destCha
{
try
{
await StartCopyFromUri(taskId, destChannel, srcBlob.GenerateUriWithCredentials(Channel.StorageContext), destBlob).ConfigureAwait(false);
Uri srcBlobUriWithCredentail = null;
if (Channel != null && destChannel != null &&
Channel.StorageContext != null && destChannel.StorageContext != null
&& Channel.StorageContext.StorageAccountName == destChannel.StorageContext.StorageAccountName
&& Channel.StorageContext.StorageAccount.Credentials.IsToken)
{
// if inside same account, source blob can be anonumous
srcBlobUriWithCredentail = srcBlob.Uri;
}
else
{
srcBlobUriWithCredentail = srcBlob.GenerateUriWithCredentials(Channel.StorageContext);
}
await StartCopyFromUri(taskId, destChannel, srcBlobUriWithCredentail, destBlob).ConfigureAwait(false);
}
catch (StorageException ex)
{
Expand Down