Back to previous page

Errors using azcopy and azure-cli to copy files to Azure Storage Blobs

I’ve been working with an Azure Storage Account to host a static website (this blog) and am interested in implementing an upload process that uses azcopy or the azuret-cli.

Both tools are good for the job, and have minor efficiency improvements, depending on your scenario and scripting skills. On first impressions, azcopy is great to perform a full directory sync, whereas the azure-cli is the friend of script writers.

I’m working on a Mac at home, so luckily both tools are compatible with Mac and Linux environments.

With either azure-cli and azcopy, I can see how it would be easy to set up a deployment pipeline, triggered by a git merge a repo hosted in Azure DevOps, to automate the publishing of my content (blog posts).

Error when using azure-cli

My specific scenario is to deploy blobs to a Azure Storage Account Blob with the container name of $web$web is the container name given by the Admin Portal when a static website is created in your Storage Account.

After installing the azure-cli on my environment, I would execute the login command:

However, executing the command to perform a Blob upload:

I received the following error:

With a full exception trace as follows:

Error when using azcopy (v10)

After hitting a wall with the above error I thought I’d try the alternative option: azcopy.

First step to copying files to Azure with azcopy is to generate a Shared Access Signature, which can be done in the Azure Portal. With the SAS, you can then use azcopy without logging in:

However, that command would return 37 failed file transfers (the number of files I was recursively trying to upload). So I tried an individual file, for example:

And the following error returned:

The solution to both azure-cli and azcopy errors

The solution to both errors? Escape the $ (dollars) character in the command parameter – so $web becomes $web.

The correct azure-cli command is:

And the correct azcopy command is:

Both errors occur because a value prefixed with $ in bash is considered a variable. When the command is passed in to azure-cli or azcopy, bash thinks the value of $web is blank, and passes it in as blank.

About the Author:

Mark Powney is a developer of two decades, and a SharePoint consultant of one. Today he builds modern Office 365 experiences that touch tens of thousands of people world-wide on a daily basis. He also spends time in the world-wide developer community, contributing to open source projects in and around the Azure and Office 365 ecosystem.


Powney, M. (2019). Errors using azcopy and azure-cli to copy files to Azure Storage Blobs. Available at: [Accessed: 3rd May 2019].

Share this on...

Leave a Reply

Back to previous page