Windows Azure has a cloud file storage service known as Blob Storage.
[Note: Windows Azure Storage is broader than just Blob Storage, but in this post I will ignore its sister services Table Storage (a NoSQL key/value store) and Queues (a reliable queuing service).]
Before we get into the tricks, it is useful to know a bit about Blog Storage.
- At its core it is a file system in the cloud, albeit a highly reliable, super-scalable, and extremely versatile one. It stacks up VERY COMPETITIVELY against the other cloud players.
- Windows Azure Storage supports geo-redundancy (making a copy of your blob data in another data center – depicted as the lines between data center regions in the maps shown in my recent Where’s Azure? post ).
- Microsoft is committed to keeping Blob storage priced on par with Amazon: http://blogs.msdn.com/b/windowsazure/archive/2014/01/24/storage-price-match.aspx
- Interacting with Storage need not be programmatic, as there are some handy tools. Check them out here: http://storagetools.azurewebsites.net/
The code below is very simple – it uploads a couple of files to Blob Storage. The files being uploaded are JSON, so it includes proper setting of the HTTP content-type and sets up caching. Then it lists a directory of the files up in that particular Blob Storage container (where a container is like a folder or subdirectory in a regular file system).
The code listed below will work nicely on a Windows Azure Dev-Test VM, or on your own desktop. Of course you need a Windows Azure Storage Account first, and the storage credentials. (New to Azure? Click here to access a free trial.) But once you do, the coding is straight-forward.
- For C#: create a Windows Console application and add the NuGet packaged named “Windows Azure Storage”
- For Node.js: run “npm install azure” (or “npm install azure – –global”)
- For Python: run “pip install azure” to get the SDK
- We don’t cover it here, but you could also use PowerShell or the CLI or the REST API directly.
Note: these are command line tools, so there isn’t a web project with config values for the storage keys. So in lieu of that I used a text file on the file system. Storage credentials should be stored safely, regardless of which computer they are used on, so beware my demonstration only using public data so my storage credentials in this case may not be as damaging, if lost, as some others.
Here’s the code. Enjoy!
SDK Source for Python: https://github.com/WindowsAzure/azure-sdk-for-python
SDK Source for Node.js: https://github.com/WindowsAzure/azure-sdk-for-node
Storage SDK Source for .NET: https://github.com/WindowsAzure/azure-storage-net
Storage Client Library 3: http://msdn.microsoft.com/en-us/library/dn495001%28v=azure.10%29.aspx