1

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?

6
  • Can you get rid of '' (single quotes) around your SAS token and try again? Commented Feb 22, 2022 at 17:35
  • I already tried that, actually I tried multiple combinations of escape characters. When I get rid of '' then I get: 'st' is not recognized as an internal or external command, operable program or batch file. 'se' is not recognized as an internal or external command, operable program or batch file. .... Commented Feb 22, 2022 at 17:42
  • Can you try removing the double quotes (")? I just tried by removing that and was able to upload the blobs. Commented Feb 22, 2022 at 17:59
  • Same error as above, both in old PowerShell and PowerShell 7. I have latest Azure CLI tools. I don't know what can be wrong then.. @Guarav Mantri are you using the SAS token copied directly from Azure Portal? Commented Feb 22, 2022 at 18:12
  • Yes. I tried both with and without ? in front of the SAS Token and it worked in both cases. Can you share the actual signature value? Commented Feb 22, 2022 at 18:14

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

The problem we're facing is in powershell core 7.x. Had to use '"<sastoke>"' to get it work.
Thank you aDisplayName. This fixed my issue with AZCopy and Powershell. I was going crazy because the command syntax that worked in Linux bash wasn't working in Powershell at all, and the error given was an unhelpful "Authorization Failed". I knew the token was good because it worked in Bash.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.