'Azure CLI and SAS Token issue in PowerShell

I generated SAS token in Azure Portal and trying to use it to upload files to blob storage:

az storage blob upload-batch --source ./test --destination '$web' --account-name 'myaccountname' --sas-token '"sp=racwl&st=2022-02-22T17:04:19Z&se=2022-12-23T01:04:19Z&spr=https&sv=2020-08-04&sr=c&sig=mXXXXXXXXXXXXXXXXXXXXXXXXXXONfAA%3D"'

But above command gives me following error in PowerShell:

<AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail>

I am literally copying the SAS Token from Azure Portal so how on earth can it be malformed?



Solution 1:[1]

We have ran the same az storage blob upload-batch cmdlet in our local environment( which is running with powershell v5.1) & we are able to upload the files from local machine to the storage account as shown in below.

Here is the cmdlet we have used :

az storage blob upload-batch --account-name <strgAccountName> -s <sourcefilepath> -d 'https://xxxxxx.blob.core.windows.net/cont1' --sas-token '<generatedSAStoken from portal>'

Here is the sample Output for reference:

enter image description here

Note:

To the above cmdlet, We have tried passing the SAS token with appending(single quote+ question mark) '?' & without passing in single quote's to the --sas-token flag in both the cases we are able to upload the files from local machine to Azure storage container.

Solution 2:[2]

I don't know what was wrong, but suddenly it started to work with '"sastoken"' format. Thanks for your responses.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VenkateshDodda-MSFT
Solution 2 Signum