Copy blob using SAS

I have been trying for a couple of days to find an easy way (read:  using tools) to copy blobs in Windows Azure Storage, not by using management keys but using Shared Access Signature (SAS).

Sounds simple enough.  I remembered the AzCopy tool.  I looked around and found a blog post explaining how to use it with SAS, using the DestSAS switch.

I spent hours and I could never make it work.  For starter, AzCopy is designed to copy folders instead of individual files.  But also, I could never get the SAS to work.

After those lost hours, I turned around and look at the Storage REST API.  Turns out you simply need to do an HTTP PUT in order to write a blob into a container.  If the blob doesn’t exist, it creates it, if it exists, it updates it.  Simple?

In PowerShell:

$wc = new-object System.Net.WebClient

$wc.UploadFile(<Blob Address>, "PUT", <Local File Path>)

The Blob Address needs to be the URI containing a SAS.



2 thoughts on “Copy blob using SAS

  1. For me, it works fine, with an SAS, uploading files from my local computer to a Blob Container.
    After a bit of trial error, It worked with:
    azCopy.exe /Source: /Dest:”?”
    and not . Don’t forget the ? character. And can be just obtained with Azure Storage Explorer.

    I used this utility, althougth It doesn’t seem to be much more faster than just dragging and dropping files using Azure Storage Explorer.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s