Consuming Windows Azure Blob Storage from Ruby
October 6, 2009
Hey Folks, today I’m proud to announce my first release of the waz-blobs ruby gem, for interacting with Windows Azure Blob Storage from Ruby programming language.
Yes, it’s 100% organic Ruby code, there’s no strange Microsoft library that you need to consume and even better it was written and tested on Mac OS X and Ubuntu 8.10. This post is about the motivation, and design process I’ve taken. Here you will find a minimal reference to the code, if you’re looking for the bits go straight to http://github.com/johnnyhalife/waz-blobs/ that includes the whole API documentation.
Motivation
Interoperability, fun and inspiration! Those three words are the base of this whole experience, from those OSS Fan thinking “why would I go for Windows Azure Storage? I’ve have my App written 100% ruby and runs on my custom built linux distro!”, here is the summary of the thinking I’ve been doing when I was trying to understand whether to write the API or not:
- It’s solid. Although it’s on CTP, it has been out for almost a year and during the different version it has demonstrated some basic fundamentals covered on Distributed Storage and the speed it’s really good.
- Ruby’s alternatives for serving static files isn’t great. I love Ruby, it has slowly became the language of my preference on the last year, but we have to admit that serving static files it’s better when outside our Ruby App server.
- It’s interoperable. As I started this post, the code available at http://github.com/johnnyhalife/waz-blobs/ is 100% organic ruby code, it’s based on the RestClient API written by Addam Wiggins from Heroku that can be found on http://github.com/adamwiggins/rest-client/. The code is based on the WAZ Rest API available at http://msdn.microsoft.com/en-us/library/dd135733.aspx
- It works great from Heroku. I spend my spare time hacking on pure Ruby and most of my project end up on Heroku (by far the best Ruby Hosting Platform on the Clouds). As you can see on Heroku Docs, their recommendation is to go for AWS-S3, and I don’t like when my choices are limited, I wrote the gem just to have an alternative for S3 when hosting on Heroku.
Getting started with the waz-blobs API
First of all, if you just want to use it just get it from the gems repository like the following:
gem install waz-blobs --source http://gemcutter.org
And here’s some basics
require 'waz-blobs'
# Save your configuration info
WAZ::Blobs::Base.establish_connection!(:account_name => "name", :account_key => "key")
# creates a container
container = WAZ::Blobs::Container.create('my-container')
# stores a blob with custom properties (metadata)
blob = container.store('my-blob.txt', 'this is the content of my blob', 'plain/text')
# return a specific blob from a container
blob = container['my-blob.txt']
# retrieves a blob value
blob.value
The complete API reference and source code can be found at http://github.com/johnnyhalife/waz-blobs/, feel free to download, fork it, and submit patches.
Next Steps
During the next days, I’ll continue using this and probably refactoring or bug fixing. In the near future (don’t know how quick yet), I’ll get the WAZ Queues API too.
While I work on Queues, fork me on GitHub and consider yourself invited to submit as many patches as you want.
thanks and read you soon,
~johnny
October 6th, 2009 at 10:40 pm
Hi Johnny,
Thanks for sharing this, this is very cool to see bridges like this to Windows Azure.
JC
October 6th, 2009 at 11:19 pm
[...] Johnny Halife’s Blog » Blog Archive » Consuming Windows Azure Blob Storage from Ruby blogs.southworks.net/jhalife/2009/10/06/consuming-windows-azure-blob-storage-from-ruby – view page – cached Hey Folks, today I’m proud to announce my first release of the waz-blobs ruby gem, for interacting with Windows Azure Blob Storage from Ruby programming language. — From the page [...]
October 8th, 2009 at 12:53 am
Consuming Windows Azure Blob Storage from Ruby…
Thank you for submitting this cool story - Trackback from progg.ru…
October 9th, 2009 at 3:02 pm
[...] on the previous post I wrote about the Blobs API, this post isn’t about API documentation. It’s about all [...]