Copy blob using SAS
Solution ·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.
Enjoy!
2 responses