azureazcopy

AzCopy copy run from a batch file in Windows command prompt failure


I'm using AzCopy to copy a file from local server to Azure and coming up with the following failed operation is the command is run from a batch file. If the same command is run from the command prompt the operation is successful.


Run from a batch file - fails:

C:\ftp>AzCopy /Source:C:\ftp\ /Dest:"https://companystrg01.file.core.wind ows.net/bss?sv=2016-05-31&si=bss-supersecretstring" /S

Incomplete operation with same command line detected at the journal directory "C :\Users\Administrator\AppData\Local\Microsoft\Azure\AzCopy", do you want to resume the operation?

Choose Yes to resume, choose No to overwrite the journal to start a new operation. (Yes/No) y

[2018/03/19 13:50:22][ERROR] C:\ftp\board\file.TXT: The transfer fail ed.

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

Time:Mon, 19 Mar 2018 03:50:05 GMT Finished 0 of total 1 file(s). [2018/03/19 13:50:22] Transfer summary:

Total files transferred: 1

Transfer successfully: 0

Transfer skipped: 0

Transfer failed: 1

Elapsed time: 00.00:00:04

================================

Run form a command line - succeeds:

C:\ftp>AzCopy /Source:C:\ftp\ /Dest:"https://companystrg01.file.core.wind ows.net/bss?sv=2016-05-31&si=bss-supersecretstring" /S

[2018/03/19 13:56:57][WARNING] The command line "AzCopy /Source:C:\ftp\board\ /D est:"https://companystrg01.file.core.windows.net/bss?sv=2016-05-31&si=bss-supersecretstring" /S" in the journal file "C:\Users\Administrator\AppData\ Local\Microsoft\Azure\AzCopy\AzCopy.jnl" is different from your input.

[2018/03/19 13:56:57][WARNING] Incomplete operation with different command line detected at the journal directory "C:\Users\Administrator\AppData\Local\Microsof t\Azure\AzCopy".

Do you want to overwrite the journal to start a new operation? Choose Yes to overwrite, choose No to cancel current operation. (Yes/No) y Overwrite https://companystrg01.file.core.windows.net/bss/file.TXT w ith C:\ftp\board\file.TXT? (Yes/No/All) y Finished 1 of total 1 file(s). [2018/03/19 13:57:06] Transfer summary:

Total files transferred: 1

Transfer successfully: 1

Transfer skipped: 0

Transfer failed: 0

Elapsed time: 00.00:00:09

C:\ftp>


I would appreciate some guidance.

Thank you.


Solution

  • You need to escape the special characters in your batch file. See a similar question here: Batch character escaping