File transfer from blob storage using azure cli
Step by step instructions on how to move files and directories to and from azure blob storage.
File transfer from blob storage using azure cli
Downloading and uploading files from blob should be simple but I often come across a lot of errors while doing so. This blob documents the steps that have worked for me.
This is how azure blob fits into the hierarchy
- microsoft account (your microsoft account like example@hotmail.com)
- subscription (each azure account comes with subscription id. Generally one subscription for each team)
- storage account (storage account contains multiple containers)
- blob storage container (this is where the actual files are stored)
- storage account (storage account contains multiple containers)
- subscription (each azure account comes with subscription id. Generally one subscription for each team)
Azure CLI
Install azure cli using the instructions mentioned here.
this is the sdk/tool through which we can download/upload/delete or list files and folders in blob storage.
Do these for convenience
1
2
3
4
az login
az account set --subscription <subscription id>
export AZURE_STORAGE_ACCOUNT=krishan
export AZURE_STORAGE_KEY=<storage account key from azure portal>
1. List blob
1
az storage blob list -c <container-name>
Upload
1
az storage blob upload -f file.txt -c <container-name> -n file.txt
Download
1
az storage blob download -f file.txt -c <container-name> -n file.txt
upload dir
Let’s say we want to save model checkpoints
1
az storage blob upload-batch -d mtl/checkpoints -s /home/azureuser/MTL/checkpoints
Viewing the file structure
Download and install Azure Storage Explorer if you prefer GUI.
Reference:
This post is licensed under CC BY 4.0 by the author.