Running Orchard on Windows Azure

I was already running an Orchard installation on some shared .NET hosting. But as with most of the shared hosting environments, I was very limited with what I could do and what not. Next to that, almost every action required an intervention of the support team as there seemed to be some issues with their automated system. It also made it impossible to easily install new modules or even upgrade my Orchard instance to a later version. By now, my old blog is running several versions behind and is getting filled up with (luckily hidden) spam comments.

As the latest release (version 1.7) was getting closer, the plans to move to Windows Azure were made and that’s where we are now. Even though I’m not a web developer, at least I can do what I want now (and screw up my installation), without being hold back by the system. I’m pretty sure a few more tweaks will have to be made during the coming weeks, like I’d like to offload my comments to Disqus, but right now the Orchard.Disqus module isn’t compatible with the latest version yet (and this was already a fix on the original module in the gallery).

The easiest way by far to get Orchard running on Windows Azure is to install it through the gallery when creating a new website. However, I did want to offload all my media files to Azure blob storage. For Azure websites, this wasn’t available out of the box yet, but a post on the OrchardCMS forum explained me how to do it. It comes down to pulling the latest source code, reference Orchard.Azure, alter 4 constructor calls and provide a config setting. At first I could store files, but wasn’t getting them back into my media library. A late night chat with Sébastien made it clear that this was a AJAX cross domain issue between websites and storage. A few days later the Azure team itself got this fixed. We also discussed the trick for Azure storage and guess what … a few days later he had created a new Orchard.AzureBlobStorage module in the 1.x branch. So you can expect this to be released with the version 1.7.1 in the upcoming weeks.

Once you got your website running, scale it up at least to a Shared instance so you can set your custom domain. As I’m using Windows Azure blob storage for my media, I wanted to do the same there. As long as you got access to your own domain name to change CNAME records, it’s just a matter of waiting for the DNS to propagate. As my old domain was managed by a third party, which again asked for a support call, I just created a new domain to get this blog going and no longer be dependant on third parties. This also gives me the time to move my old blog posts over whenever I got spare time to filter out the spam comments and update all media links to blob storage.

The final problem that I wanted to tackle is my website going idle and the app pool getting recycled. If this happens, your next visitor will have to wait quite a lot longer than usual before his page loads. As we’re on Windows Azure already, I created a mobile service with a scheduler. This scheduler executes following script (from Sandrino Di Mattia) every 15 minutes to call my site:

function KeepSitesAlive() {
 warmUpSite("http://yoursitehere/");
}

function warmUpSite(url) {
 var req = require('request');
 req.get({ url: url }, function(error, response, body) {
 if (!error) {
  console.info("ok: " + url);
 } else {
  console.error('error warming up: ' + url + ': ' + error);
 }
});
}

As traffic to your site picks up over time, the script might no longer be needed, but I guess the 4 extra hits an hour won’t hurt you either. There are several services out there to check if your site is still running, like Pingdom, and some of them will most likely use a simple http request as well. So many ways to make sure your app pool doesn’t get recycled too often because of idling.

During the next weeks, you’ll see my old posts pop up here and in the mean time they’re still online on my old blog. Once they’re all moved, 301 redirects will be in place to forward traffic.

Licensed under CC BY-NC-SA 4.0; code samples licensed under MIT.
comments powered by Disqus
Built with Hugo - Based on Theme Stack designed by Jimmy