Search code examples
azure-blob-storageazcopy

AzCopy in Batch file


Am trying to copy files to Azure Blob using AzCopy.

When execute AzCopy at command line it works fine, but executing same through .bat file getting issues.

ex: azcopy copy "c:\xxxxxxx\20210304" "https://xxxx.blob.core.windows.net/xxxxxxxdrop?sp=rw&st=2021-03-04T05:06:45Z&se=2021-03-04T13:06:45Z&spr=https&sv=2020-02-10&sr=c&sig=xxxxxxxxxxxxxxxxxxxoqxx6dJczN26Mc%3D" --recursive

what is the best way to achieve this


Solution

  • Some special characters in .bat file should be escaped. In the command you provided, the % in the sas_token should be replaced by %%.

    If the issue is that the azcopy command cannot be found, you should specify the full path of the azcopy.exe in your .bat file.

    I gave it a try at my side, it works fine in .bat file. Here is the screenshot:

    enter image description here

    By the way, here is an issue about chars-escape in .bat file.