Skip to content

Commit

Permalink
[Storage] Added a breaking warning : download blob will block input p…
Browse files Browse the repository at this point in the history
…arameter -AbsoluteUri and -Context together (Azure#26377)

* [Storage] Added a warning for an upcoming breaking change for download blob with parameter -AbsoluteUri will not allow parameter -Context be input together.

* add 1 more change log

* fix warning not show problem
  • Loading branch information
blueww authored Oct 28, 2024
1 parent 885318e commit f78468a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
- Additional information about change #1
-->
## Upcoming Release
* Added a warning for an upcoming breaking change for download blob will block input parameter -AbsoluteUri and -Context together.
- `Get-AzStorageBlobContent`
* Revised AzureStorageBlob construct logic to make it more stable.

## Version 7.4.0
* Added a warning for an upcoming breaking change for removing references to "Microsoft.Azure.Storage.File"
Expand Down
2 changes: 2 additions & 0 deletions src/Storage/Storage/Blob/Cmdlet/GetAzureStorageBlobContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using Track2Models = global::Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs;
using Azure.Storage;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;

namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
{
Expand Down Expand Up @@ -112,6 +113,7 @@ public SwitchParameter CheckMd5

private bool checkMd5;

[CmdletParameterBreakingChangeWithVersion("AbsoluteUri", "13.0.0", "8.0.0", ChangeDescription = "When download blob with parameter AbsoluteUri (alias Uri, BlobUri), parameter Context will not be allowed to input together.")]
[Alias("Uri", "BlobUri")]
[Parameter(HelpMessage = "Blob uri to download from.", Mandatory = true,
ValueFromPipelineByPropertyName = true, ParameterSetName = UriParameterSet)]
Expand Down
15 changes: 1 addition & 14 deletions src/Storage/Storage/Blob/StorageDataMovementCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,7 @@ protected override void BeginProcessing()

protected virtual void DoBeginProcessing()
{
CmdletOperationContext.Init();
CmdletCancellationToken = _cancellationTokenSource.Token;
WriteDebugLog(String.Format(Resources.InitOperationContextLog, GetType().Name, CmdletOperationContext.ClientRequestId));

if (_enableMultiThread)
{
SetUpMultiThreadEnvironment();
}

OpContext.GlobalSendingRequest +=
(sender, args) =>
{
//https://github.com/Azure/azure-storage-net/issues/658
};
base.BeginProcessing();

OutputStream.ConfirmWriter = (s1, s2, s3) => ShouldContinue(s2, s3);

Expand Down
6 changes: 3 additions & 3 deletions src/Storage/Storage/Common/AzureStorageBlob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public static CloudBlob GetTrack1Blob(BlobBaseClient track2BlobClient, StorageCr
return new InvalidCloudBlob(track2BlobClient.Uri, credentials);
}

if (credentials.IsSAS) // the Uri already contains credentail.
if (credentials != null && credentials.IsSAS) // the Uri already contains credentail.
{
credentials = null;
}
Expand Down Expand Up @@ -497,12 +497,12 @@ public static BlobClient GetTrack2BlobClient(BlobBaseClient blobBaseClient, Azur
return (BlobClient)blobBaseClient;
}
BlobClient blobClient;
if (context.StorageAccount != null && context.StorageAccount.Credentials != null && context.StorageAccount.Credentials.IsToken) //Oauth
if (context != null && context.StorageAccount != null && context.StorageAccount.Credentials != null && context.StorageAccount.Credentials.IsToken) //Oauth
{
blobClient = new BlobClient(blobBaseClient.Uri, context.Track2OauthToken, options);

}
else if (context.StorageAccount != null && context.StorageAccount.Credentials != null && context.StorageAccount.Credentials.IsSharedKey) //Shared Key
else if (context != null && context.StorageAccount != null && context.StorageAccount.Credentials != null && context.StorageAccount.Credentials.IsSharedKey) //Shared Key
{
blobClient = new BlobClient(blobBaseClient.Uri,
new StorageSharedKeyCredential(context.StorageAccountName, context.StorageAccount.Credentials.ExportBase64EncodedKey()), options);
Expand Down

0 comments on commit f78468a

Please sign in to comment.