Upload a file from bash
This short demo shows how one can upload a file into Azure storage, using just basic utilities (i.e. no Microsoft-provided tooling).
Requirements
To do so, we need a few requirements satisfied:
bash
,curl
andjq
The
cURL
utility must be locally installedThe
jq
utility (https://stedolan.github.io/jq/) must be locally installed
You need to have an Azure storage account
In that storage account, there needs to be a storage container already created
You need to have the
Storage Blob Data Contributor
role assigned
Obviously you need some local file
Given that we'll upload the file in a single shot, it must be less than 5000 MiB in size
How it works
The script attempts a device code signin to the given Azure AD tenant, requesting a token for Azure storage
Once the script outputs the device code, you need to open
https://microsoft.com/devicecode
in a web browser and punch in the device codeThe script locally computes the MD5 hash of the file (using
md5sum
,awk
,xxd
andbase64
), to ensure upload errors will be catchedThe script uploads the file to blob storage.
Last updated