Skip to content

Commit

Permalink
[Storage] Added a warning for an upcoming breaking change for downloa…
Browse files Browse the repository at this point in the history
…d blob with parameter -AbsoluteUri will not allow parameter -Context be input together.
  • Loading branch information
blueww committed Oct 17, 2024
1 parent 6a3f868 commit 612a9f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- 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`

## 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
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 612a9f5

Please sign in to comment.