** Update: BlogEngine.NET is now included as part of Windows Azure’s Website App Gallery **
Currently the Gallery only includes version 18.104.22.168 of BlogEngine.NET, which is a couple of versions behind now. If you want to install the latest version then the steps below should still be applicable.
Windows Azure Web Sites is one of the new features in Windows Azure announced by Scott Guthrie on his blog post Meet the New Windows Azure. Azure Web Sites are akin to the shared hosting model, where many sites are hosted under one installation of IIS inside of a single VM. Azure puts a bit of a spin on this concept by allowing scale out of the Web Site to multiple VMs and the ability to reserve entire VMs just for its usage.
WindowsAzure.com describes Azure Web Sites as follows:
Build highly scalable web sites on Windows Azure
Quickly and easily deploy sites to a highly scalable cloud environment that allows you to start small and scale as traffic grows.
Use the languages and open source apps of your choice then deploy with FTP, Git and TFS. Easily integrate Windows Azure services like SQL Database, Caching, CDN and Storage.
This functionality is currently free for up to 10 websites during the technical preview. However, I can’t imagine it being all that expensive once it comes out of preview.
The biggest feature that really stands out IMO is the ability to just use Web Deploy in Visual Studio for deployments. Aside from the new publish profile it’s not necessary to change anything else about the project/solution. All of this drastically reduces the barrier to entry for anyone wanting to get started with Windows Azure.
With that said, we’re going to go through the process of deploying BlogEngine.NET to Windows Azure using the new Web Sites features and see that things are demonstrably easier than what was required in the past. Additionally, this should give us a quick run through of the new management portal for Azure (more on this below).
Here’s an overview of what we’ll need:
- Windows Azure Account (you can sign up for a 90 day free trial)
- Visual Studio 2010 SP1 or higher (SP1 is required for the Azure SDK)
- BlogEngine.NET WAP Project source (detailed below)
- Windows Azure SDK 1.7 or higher, if using VS 2010 SP1 (links provided below)
If you don’t already have an Azure account, you’ll need to sign up for one before you can continue. Again they have a 90 day free trial, so there’s no hassle. Once you have your account set up, we’ll need to enable the Web Sites preview, which also enables the preview of the new management portal. This happens to be relatively painless.
After electing to use the preview portal you’ll get a quick guided tour detailing its new features. With the new portal and the Web Sites option enabled, we can finally create an Azure Web Site.
There are several other blog engines in the gallery, unfortunately BlogEngine.NET isn’t one of them. Select Quick Create since we’re going to do a basic/default installation of BlogEngine.NET. If we were backing our BlogEngine.NET install with a Sql Server we’d select Create with Database instead of Quick Create. Note the URL field can be entered as whatever you want it to be.
Once finished we should now have a running web site, just with nothing deployed to it yet
Next up we need to go to the management screen and pull down the publish profile. This tells Visual Studio how to publish to our Azure Web Site.
Azure SDK Install
If you’re using Visual Studio 2012 RC, you can skip this step. For those running VS 2010 SP1, you’re going to need to install the Azure SDK 1.7 or greater in order for VS 2010 to use the publish profile. Ultimately this just updates the publish options in VS 2010 to be like that of VS 2012’s.
You can download the SDK from here: https://www.windowsazure.com/en-us/develop/downloads/
I installed the .NET Full version, but Windows SDK only should work fine.
BlogEngine.NET Web Application Project
The default download/install of BlogEngine.NET is an “old school” web site project, which isn’t exactly compatible with Windows Azure (there’s a way, it’s just not easy). Web application projects are compatible with Windows Azure out of the box. Earlier this year the only option for BlogEngine.NET was to manually do the conversion, which wasn’t exactly straight forward. See my blog post: Converting BlogEngine.NET 2.5 to a Web Application for more info.
Luckily enough, when the BlogEngine.NET developers released 2.6 they also released a branch that is already converted to a web application. You can find more information on this post on rtur’s website (listed as coordinator for BlogEngine.NET) :
The WAP version is under a different codeplex repository located here: http://blogengineweb.codeplex.com/. As opposed to downloading the precompiled version we’re going to pull down the source since using the publish profile in Visual Studio requires a functioning build.
Download the source changeset for BlogEngine.NET 2.6 as a WAP from codeplex.
Make sure to extract this to a directory hierarchy that does not have spaces in it. The XCopy post build steps in BlogEngine.NET weren’t set up to work with a directory structure containing spaces.
Open it up in Visual Studio and make sure everything builds. Before we’re able to publish we’ll need to do a little project house cleaning. BlogEngine.NET ‘s WAP project has a handful of files that are missing yet still part of the project. We just have to remove the references to these files, otherwise the publish process will halt on them.
Delete the files from the following locations (should be easy spot with the exclamation marks) as seen below.
Now we’re ready to publish. Right click on BlogEngine.Web and select Publish.
This should bring up the publish dialog, which should look like the image below. If it looks different and it doesn’t have a spot to import the publish profile, then the Azure SDK may not have been installed or may need to be reinstalled.
Import the publish profile and all the info necessary to publish to the azure website should be prepopulated.
Hit the publish button and check the build output to see if the publish was successful.
Navigate to the site url detailed in the build output and you should be good to go.
One thing to mention is that although we’ve deployed BlogEngine.NET to Windows Azure Web Sites, that in itself doesn’t make it inherently scalable. If we plan to scale out or have finally gotten to the point where it’s necessary to do so) we’d have to attack a few extra design considerations, which could be an entirely new blog post. I’ll just scratch the surface here of what needs to be considered.
By default BlogEngine.NET stores blog posts and their associated images in the file system. When scaling out both posts and images will need to be centralized and available across multiple hosted instances of BlogEngine.NET. In the simplest sense, this could be accomplished by switching over to Sql Azure for post and image storage, since BlogEngine.NET supports this natively.
Alternatively, you could use Azure’s Blob storage (see Azure Data management for an overview, Blob storage is described at bottom of page) to store the images individually, however this will require an additional BlogFileSystemProvider to be created so BlogEngine.NET can make use of it. Blob storage is made for this type of storage and is significantly cheaper per GB than Sql Azure.
Personally, I like to compress my post images after the fact using OptiPNG, which runs at the command line and processes a directory of png images. In which case, neither Sql Azure nor using Blob storage directly would be all that helpful for me. I might lean towards Azure Drive (also described in Azure Data management), which stores a VHD in Blob storage, but acts like a shared drive. It’s a little clunky to work with but it’s another option to consider depending on your needs.
As a side note, BlogEngine.NET doesn’t make use of session, so there are no changes necessary from that standpoint.
All in all, Azure Web Sites seem very easy to work with. Microsoft did a good job in making this a hassle free experience. The installation of BlogEngine.NET wasn’t that bad, however, I would of preferred for it to already be in the gallery, which would of meant we wouldn’t have had to deal with publishing from Visual Studio at all. It’ll be interesting to see how Azure Web Sites will ultimately be priced. Priced right, this could set a new bar for shared hosting standards and be a good entry point for those looking to get started with Windows Azure.