Azure-storage-azcopy: azcopy Sync with SAS in batch file fails although same command in cmd works

Created on 22 Jan 2019  路  13Comments  路  Source: Azure/azure-storage-azcopy

Which version of the AzCopy was used?
10.0.5

Which platform are you using? (ex: Windows, Mac, Linux)
Windows

What command did you run?
azcopy sync "existing location" "https://mystorage.blob.core.windows.net/container?SAS" --recursive --force

What problem was encountered?
When running command in cmd prompt it works fine. However, running it in a batch file fails with:


Description=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:0e1f4f73-901e-0001-3855-b2f733000000
Time:2019-01-22T13:19:35.6811212Z, Details:
AuthenticationErrorDetail: Signature size is invalid
Code: AuthenticationFailed
GET https://mystoragelocation.blob.core.windows.net/container?comp=list&restype=container&se=2025-01-21t17%3A07%3A50z&sig=REDACTED&sp=rwdlacup&spr=https&srt=sco&ss=bfqt&st=2019-01-21t09%3A00%3A50z&sv=2018-03-28&timeout=901
User-Agent: [AzCopy/10.0.5-Preview Azure-Storage/0.3 (go1.10.3; Windows_NT)]
X-Ms-Client-Request-Id: [71aee875-f689-457c-63d1-28d253b5e68a]
X-Ms-Version: [2018-03-28]


How can we reproduce the problem in the simplest way?
Try as described above.

Have you found a mitigation/solution?
No

Most helpful comment

Found the reason: https://www.shadowsplace.net/1907/windows/azcopy-batch-file-with-sas-token-the-remote-server-returned-an-error-403-forbidden

If you have a % in the SAS key, you need to add another % in front for the batch file to run.

All 13 comments

Hi @telekallis, thanks for reaching out!

Could you please double-check whether the same SAS is being used? This doesn't sound like a problem in AzCopy.

Hi, I am 100% sure they are exactly the same. Karl

Same issue here. Does not work from .bat or .cmd , but works from .ps1

I wanted to run the batch file from a Scheduled Task which did not work (see above). However, when I ran the azcopy directly from the task with added arguments, it worked.

@telekallis can you check you bat is running at an elevation CMD prompt "run as admin"? I was getting a similar issue, my bat was just shutting down as soon as the sync started. Running it elevated fixed the problem. v10.0.0.7

@telekallis also i note your using 10.0.5... try 10.0.7

User-Agent: [AzCopy/10.0.5-Preview Azure-Storage/0.3 (go1.10.3; Windows_NT)]

@telekallis I'm closing this issue for now, as it doesn't seem like an issue related to the tool itself.

On a side note, the sync command was rewritten and released in 10.0.8. Please give the new version a try and let us know if you still encounter any problem.

Here is a wiki explaining how the new sync command works. Please feel free to reach out if you have any question or concern.

I am having the same issue with 10.0.8-preview. If I run the copy command from the command line it works but not when executed from a batch file. The exact same command. Elevated command does not fix the issue.

Error 403, server failed to authenticate the request. Make sure the value of the Authorizatrion header is formed correctly.

using like this:
azcopy cp "https://blobstorage/container/*?SAS" "c:\local\folder" --recursive=true

Found the reason: https://www.shadowsplace.net/1907/windows/azcopy-batch-file-with-sas-token-the-remote-server-returned-an-error-403-forbidden

If you have a % in the SAS key, you need to add another % in front for the batch file to run.

Thanks a lot @fglebel!

@fglebel Thanks for finding that blog post.

Thanks @fglebel! This helped a lot!

Thanks @fglebel! This helped me a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LoofahBu picture LoofahBu  路  3Comments

Mmdixon picture Mmdixon  路  3Comments

IGx89 picture IGx89  路  4Comments

wahalulu picture wahalulu  路  3Comments

colemickens picture colemickens  路  5Comments