Today I committed support for running NServiceBus on the Azure cloud to the trunk. Also included is a sample application that demonstrates  how to build NServiceBus solutions for Azure.

Running the sample

  1. To run the sample you have to install the Azure SDK and the Azure tools for Visual Studio. The easiest way to do this is through the  Web Platform Installer. The azure tools are located under “Developer tools” ( If you can’t see them you have to enable them in “options” for the installer)
  2. Once you have tools installed you can get the latest NServiceBus trunk from subversion or download the latest build from our CI. The sample is included in the samples folder
  3. Start up the “AzureService” solution in Visual Studio and hit F5 (NServiceBus defaults to Development Storage if no configuration section is present, more on this later) so you should see the Development. Storage and Development Fabric services start up.

That should be it, the sample should now run in the development fabric on your machine.


The Azure queues support is configured using the fluent API

var config = Configure.With()

If no configuration section is found NServiceBus will default to your local development storage. To use your personal Azure storage with the sample add the following to the configuration files (web.config, app.config):

AccountName="{Your account name}"
Base64Key="{Base64 key for your account}" />

This configures NServiceBus to create and use queues on your Azure storage account. If you hit F5 again you should see the application start in your local fabric but this time the data is stored on Azure. Cloud Storage Studio is a great tool for managing you storage accounts both locally and on the cloud. The final step is to deploy the entire solution and run it completely on Azure. To do this “publish” the project in Visual Studio and upload the AzureService.cspkg and the ServiceConfiguration.cscfg to your Azure account. Detailed instructions on how to deploy solutions to Azure can be found here.

The sample application is currently running on my own Azure account, please try it out!http://nservicebus-demo.cloudapp.net (And yes my web design skills sucks :)

The sample is doing some simple send/receive and publish/subscribe operations between a WebRole and a WorkerRole. Please take look at the source code for the details.

Considerations when running NServiceBus on Azure

Azure has some limitations that might affect the way you have to design your NServiceBus solutions:

  • Maximum message size is 8kb. Message size has always been a consideration given that MSMQ has a fixed limit of 4 Mb but the 8kb limit will probably cause problems for users that transports large messages on NServiceBus. There are plans to introduce a “data bus” concept to NServiceBus to allow users to transport larger messages.
  • Messages are kept in the Azure Queues for at most 7 days. This shouldn’t be a big problem for normal usage (unless your endpoints are down for more than 7 days that is). But this also means that we can’t use the queues for subscription storage in the same way as we do with MSMQ.
  • All queue names on Azure must be lower case. Complete naming rules here.

What’s next

Right now we support Azure Queues for transporting messages but we can only store subscriptions and sagas using in memory storage. This is of course only acceptable for demos so we are working on adding support for the available storage types that Azure offers . The fact that we have NHibernate implementations for both subscription storage and saga persistence hopefully means that we already support SQL Azure Services but this has not been tested yet. (Ayende has more on this). The next step in this area is to implement support for storing subscriptions and sagas using the Azure Table Storage.

We’re constantly trying to improve NServiceBus both in terms of technology and guidance so stayed tuned for more!