AzCopy Batch File with SAS Token: The remote server returned an error (403) Forbidden

By Jake Edwards | Thursday, August 18th, 2016 | Permalink | 7 Comments

I was recently trying to copy some files from Azure using an SAS token. It was failing with the following error;

The remote server returned an error: (403) Forbidden.
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

When run manually in the command line — it’d work.

Turns out it was purely because it was running with a batch file, the % signs (common in the SAS Signature) don’t play nice with batch files.
Changing the % in the signature to %% escaped them, and let it run normally.

Hoping this saves someone else 1 hour 😉

  1. You definitely saved my hour. Thank you so much!

    Comment by Ash — February 28, 2018 @ 4:53 am

  2. Same weird error, two hours wasted.. 🙁 Now it’s work correctly… Thanks !!!

    Comment by Leo — January 16, 2019 @ 3:16 am

  3. Thank you, thank you, thank you. I was stumped for over an hour and this worked!!!

    Comment by Krisy — April 8, 2019 @ 11:49 am

  4. Thanks for the assist – hours wasted here until I found this post.

    Comment by OBD — June 20, 2019 @ 2:33 pm

  5. Nice, you saved me of messing up!

    Comment by nicolas — July 25, 2019 @ 12:18 am

  6. Thanks so much! I was trying to automate a task and had a dozen hurdles to overcome. This was the last hurdle I couldn’t get over. Thank you so much for sharing!!!

    Comment by BRV — November 1, 2019 @ 6:36 am

  7. Man, you are a legend!!!!

    Comment by Mathieu — November 8, 2019 @ 5:55 am

Leave a comment