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

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 ;)

Comments

16 Responses

  1. 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!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

 

More Posts