If you want to upload or download files to an Azure Storage Account, there are several options. Especially easy is the AzCopy tool. It allows file transfer on command line.
The second way is through the Storage REST API. Interesting are the different variants of authentication. The most common and best known way is to calculate an Authorization Token with Shared Access Key. The calculation is quite cumbersome, even though it’s well-documented and many API callings are similar. Especially for the easy transfer of the data via curl the effort with the token calculation is too big.
Much easier and more convenient is the use of the Shared Access Signature.
Create SAS Token in Azure Portal
To do this, create a SAS token that automatically has a lifetime and also different access restrictions offers.

My generated token is: ?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-05-12T23:31:24Z&st=2019-10-06T15:31:24Z&spr=https,http&sig=CsaObwbTgo%2BmRuSf5KQ6W2mMXN9jgtghP42%2BwU4kF%2B8%3D
The meaning of each parameter is listed in the corresponding Microsoft Docs.
Upload File
With this token it is now easy to upload a file to a container, in my example the file info.txt in the container1:
curl -X PUT -T /c/temp/info.txt -H "x-ms-date: $(date -u)" -H "x-ms-blob-type: BlockBlob" "https://strgzuehlke.blob.core.windows.net/container1/info.txt?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-05-12T23:31:24Z&st=2019-10-06T15:31:24Z&spr=https,http&sig=CsaObwbTgo%2BmRuSf5KQ6W2mMXN9jgtghP42%2BwU4kF%2B8%3D"
The URL contains the Storage Account (strgzuehlke) and the name of the container (container1). The token is completely appended to the URL.
Download File
The file can be retrieved the same way (but with GET instead of PUT):
curl -X GET -H "x-ms-date: $(date -u)" "https://strgzuehlke.blob.core.windows.net/container1/info.txt?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-05-12T23:31:24Z&st=2019-10-06T15:31:24Z&spr=https,http&sig=CsaObwbTgo%2BmRuSf5KQ6W2mMXN9jgtghP42%2BwU4kF%2B8%3D" hello, i'm a testfile with some lines of content to show the transfer of some data -- end --
List Files and Directories
To list files and directories, you need to refer the container in the URL and need to add the URL parameter comp=list&restype=container. The result is some XML that lists the requested informations.
curl -X GET -H "x-ms-date: $(date -u)" "https://strgzuehlke.blob.core.windows.net/container1?comp=list&restype=container&sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-05-12T23:31:24Z&st=2019-10-06T15:31:24Z&spr=https,http&sig=CsaObwbTgo%2BmRuSf5KQ6W2mMXN9jgtghP42%2BwU4kF%2B8%3D" <?xml version="1.0" encoding="utf-8"?> <EnumerationResults ServiceEndpoint="https://strgzuehlke.blob.core.windows.net/" ContainerName="container1"> <Blobs> <Blob> <Name>info.txt</Name> <Properties> <Creation-Time>Sun, 06 Oct 2019 15:54:13 GMT</Creation-Time> <Last-Modified>Sun, 06 Oct 2019 15:56:14 GMT</Last-Modified> <Etag>0x8D74A75B73593C9</Etag> <Content-Length>95</Content-Length> <Content-Type>application/octet-stream</Content-Type> <Content-Encoding /> <Content-Language /> <Content-MD5>vVh7OTGHSkh7sYzNlg7K4Q==</Content-MD5> <Cache-Control /> <Content-Disposition /> <BlobType>BlockBlob</BlobType> <AccessTier>Hot</AccessTier> <AccessTierInferred>true</AccessTierInferred> <LeaseStatus>unlocked</LeaseStatus> <LeaseState>available</LeaseState> <ServerEncrypted>true</ServerEncrypted> </Properties> </Blob> </Blobs> <NextMarker /> </EnumerationResults>
November 5, 2020 um 8:07 pm Uhr
It was really useful. Thanks!
September 23, 2023 um 3:17 pm Uhr
Thank you! This is very useful