Skip to content

Instantly share code, notes, and snippets.

@rahul286
Forked from mwinkle/azure-blob-xplat-cli-sample
Last active October 28, 2015 14:26
Show Gist options
  • Save rahul286/36bb9e1331b82996c36f to your computer and use it in GitHub Desktop.
Save rahul286/36bb9e1331b82996c36f to your computer and use it in GitHub Desktop.
Azure XPlat CLI in order to list and download blobs
# first, make sure you have downloaded the Azure XPlat CLI
# http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/#install
# eg, sudo npm install azure-cli -g
# login to Azure (will prompt for your username/password or will ask you to open link http://aka.ms/devicelogin in browser)
azure login
# optional - if you have multiple accounts
## list subscriptions
azure account list
## set subscriptions
azzure account set {{____Subscription-ID___ e.g. 145dbec1-fe5b-8cd8-9c96f881451a}}
# show all of your storage accounts
azure storage account list
# pick your storage account (eg, "_____foo_____")
# output your storage account connection string
azure storage account connectionstring show {{_____foo____}}
# this will output a string which you'll want to capture
# TODO: some shell magic to do this in oneline
# Example string: DefaultEndpointsProtocol=https;AccountName=____foo_____;AccountKey=[YOUR ACCOUNT KEY HERE]
# Please use entire string from "DefaultEndpoints.." to "..=="
# If you face a problem, surround string in quotes "..."
export AZURE_STORAGE_CONNECTION_STRING={{___STRING FROM ABOVE___}}
# validate connectivity and pick a container which has the file you want [CONTAINER]
azure storage container list
# list all blobs
azure storage blob list [CONTAINER]
# note, one cool thing is you can pass a prefix in (eg, the wasb path)
azure storage blob list [CONTAINER] /output/sample/data/f
# mk dir for [CONTAINER]
mkdir {{__CONTAINER-NAME__)} && cd {{__CONTAINER-NAME__)}
# now, downloading is easy
azure storage blob download [CONTAINER] /path/to/your/file
# TODO: a little bit of magic to go from container output to a download
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment