Upload files to Azure Storage with Azure CLI on Mac

Normally, I use Visual Studio 2015 Community Edition to browse and manage my blob file but this time I was without my Windows machine and I needed to upload few images into Azure Blob Storage.

Surprisingly there are no GUI clients compatible with Mac and I was about to write a small script in Elixir that would allow me to upload a file. Fortunately, I found the Microsoft Azure Cross Plarform Command Line before that and it fit my needs perfectly. You can do anything you desired with Azure in it.

The installation is pretty simple as you can use the node package manager.

npm install azure-cli -g

After that, add your credentials to blob storage into .bash_profile and reload your shell.

export AZURE_STORAGE_ACCOUNT=<storage account name>
export AZURE_STORAGE_ACCESS_KEY=<primary access key>

To list blobs in the container run the following command.

azure storage blob list my-container

Uploading and deleting files is pretty straightforward as well.

azure storage blob upload 1.jpg my-container 1.jpg
azure storage delete my-container 1.jpg

You can create the folder structure by prepending folder/ to the name of the file. Finally I wrote a simple script that allows you to upload all the jpg files in the current folder to the Azure Blob Storage.

find *.jpg -exec azure storage blob upload {} my-container desired/folder/{} \;


Would you like to get the most interesting content about C# every Monday?
Sign up to C# Digest and stay up to date!