Archive for April, 2011

Review of book: RabbitMQ in Action

April 26th, 2011 No comments

I was asked to do the 2nd review on the book RabbitMQ in Action by Videla & Williams (Manning Publications Co.). Link here for those interested. The book is currently available in MEAP.

RabbitMQ is an efficient, highly scalable, and easy-to-deploy queue that makes handling message traffic virtually effortless.

The book started out with a really nice historical overview of message queues. It then continued to walk through different aspects of Rabbit, giving good examples and real life stories. The prose flows nicely and the authors are quite capable of keeping ones attention.

One importing thing to note: this is a book primarily for the Unix gang. If you have never played around with Unix or Linux and Python you will most likely not be able to run the examples. I only got chapters 1 through 8 and later chapters does promise to introduce java and .NET and look at how to install and run Rabbit on other platforms, but I have not read those chapters yet, so I cannot say how they are.

This said, the book is still very recommendable for those interested in learning more about Rabbit.

Categories: Miscellaneous Tags:

FTP from Windows Azure Blob Storage

April 11th, 2011 1 comment

In connection with migrating an old CMS system to Windows Azure, I have been playing around with Windows Azure Blob Storage. The CMS system was 10 years old and written in classic ASP, using a lot of local resources mainly the file system. I’ll try go write a blob post later on the few tweaks you  have to make to enable Windows Azure to execute classis ASP.

One feature of the old CMS system was, that you could use FTP to move files to be displayed on the site. Getting files into Blob storage is relatively easy; you can even mount a Blob container using it as a (network) drive.

A colleague asked me, if it was possible to FTP files out of Blob storage (something about moving very large movie files, and trigger the process on the Azure side).

It turned out to be relatively easy to do this.

We first set up the CloudStorageAccount and the CloudBlobClient

var blobStorage = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

var blobClient = blobStorage.CreateCloudBlobClient();

blobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);


Next we get a reference to the blob entry. For the sake of simplicity we hardcode the name, but you could of course loop through all entries like this


IEnumerable<IListBlobItem> blobs = container.ListBlobs();

if (blobs != null)


    foreach(var blobItem in blobs)



and then handling each blobItem.


var containerName = "karstens";

CloudBlobContainer container = blobClient.GetContainerReference(containerName);

var fileName = "Windows Azure Platform.pdf";

var uniqueBlobName = string.Format("{0}/{1}", containerName, fileName);

CloudBlockBlob blob = blobClient.GetBlockBlobReference(uniqueBlobName);

Next we need to setup the FTP server. First some housekeeping; again, you would properly not hardcode this

var ftpServerIP = "<FTPSERVER>";

var ftpUserID = "<USERID>";

var ftpPassword = "<PASSWORD>";

var ftpFilename = "ftp://" + ftpServerIP + "//" + fileName;


To to the actual FTP transfer we use the FtpWebRequest class

FtpWebRequest ftpReq = (FtpWebRequest)WebRequest.Create(ftpFilename);

ftpReq.Method = WebRequestMethods.Ftp.UploadFile;

ftpReq.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

If the files you with to transfer, remember to set the UseBinary property to true

ftpReq.UseBinary = true;


You may also have to turn off the Proxy for the FTP request. This is done by setting the Proxy property to null


ftpReq.Proxy = null;


Next step is to download the blob entry into a bytearray, set the length on the FTP request and write the file to the (ftp)stream

Byte[] b = blob.DownloadByteArray();

ftpReq.ContentLength = b.Length;

using (Stream s = ftpReq.GetRequestStream())


    s.Write(b, 0, b.Length);



And we are done.

If you wish to automate this, you could have the WorkerRole monitor the Blob container and FTP any new items.

Categories: Azure Tags: