Sunday, October 11, 2009

My first Azure project in the cloud

I finally got around to testing a small project in the cloud and it went much smoother than I anticipated.

As the unix server we used to run pornolize.com on is currently down I decided to port the perl code to .Net. It always helps to have a concrete project when learning something new. For those who are unfamiliar with The Pornolizer, it’s basically a web page translation service like Google Translate, except it substitutes words with dirty ones. And yes, I know it’s childish :)

The project consists of a web role which serves up the start page (I decided on a new layout as well once I was at it)

pornolize-screenshot

When clicking the “Translate” button the request is picked up by a protocol handler. The handler then downloads the page you want to translate, runs the translation and serves it to the user. Before the handler ends it’s Response, it puts a log message in a queue. This queue entry is picked up by a worker role, which again inserts this into SQL Azure. I could have used a table storage, but since I had a token for SQL Azure I decided to give it a go (and it made it very simple to use Linq to SQL). Just a change of the connection string and it was up and running.

Initially I though about having the worker role do the downloading and parsing, but since I wanted low latency I decided to drop it, and chose to put in the logging instead in order to explore using a queue and SQL Azure.

One of my better weekend projects for a long time – some code cleanup and refactoring and I can move on to something else.