I had to copy all the files from the home directory into a Azure Blob container today. All the regular folders without any of the dot files and dot folders.
Azure CLI provides batch upload functionality to upload folders. But there are two issues I faced:
- I needed to copy all the folders - and I didn’t want to run the command for each folder.
- I wanted to preserve the folder structure in the container as well.
After some trial and error I settled on this one liner.
for f in */; do az storage blob upload-batch -d container-name/$f -s $f; done;
For loop take care of #1 and using the /$f
takes care of creating corresponding folders to preserve the same folder structure as in my home directory.
This assumes you already have set the AZURE_STORAGE_ACCOUNT and the AZURE_STORAGE_KEY environment variables for authentication.