Migrating an Umbraco Site from a Server to an Azure Web App

Georg Dangl by Georg Dangl in Web Development Friday, September 14, 2018

Friday, September 14, 2018

Posted in Azure Umbraco

Umbraco is a great choice for a .NET based CMS, in fact, this blog and my professional site both run on Umbraco. It is, however, still running on the full .NET Framework, with ASP.NET Core compatibility far, far out on the roadmap. This means that it's sometimes not as easy to handle as more modern solutions.

But this doesn't stop you from running it in Azure - in fact, as you'll see, it's quite easy to migrate from a regular, Windows Server hosted solution to an Azure Web App, with all the benefits included, such as auto scaling or easy blue-green deployments. My main reason for porting was to consolidate all my production infrastructure in Azure, as well as benefit from the much higher availability in contrast to a server I have to manage. Just last week, my virtual server was down for over an hour due to scheduled updates to mitigate the latest Intel processor flaws.

Migration Steps

You'll have to do three basic steps to migrate your Umbraco site while keeping all the content:

  1. Migrate your SQL database to one hosted in Azure.
  2. Copy your Umbraco media folder, which includes all your uploaded files, to an Azure Blob Storage.
  3. Update your Umbraco repository and configure it to deploy to Azure.

SQL Migration

Microsoft has made it really easy to move On Premise SQL databases to Azure. There's a simple tool, the Data Migration Assistant, which should handle everything automatically. Just follow the linked tutorial and you're good to go. You will get some warnings when migrating the database structure, related to no longer supported Xml data types, but you can ignore those. Also, make sure your target database name does not contain a . in it's name, as that will cause a bug and make it unable to connect to your Azure SQL instance.

Media Migration

In Umbraco, all the files you upload are saved by default in the media folder, relative to the root of your website. In Azure, that's a big no no. For once, disk access in your Web App tends to be not the fastest. Also, you'll run into issues as soon as you scale to multiple instances - your uploaded media files might get out of sync between instances and even disappear completely when you scale down again.

The recommended approach is to use the Azure Blob Storage service for this. Simplified, it's just storage as a service, driven by a REST API. This means you have to configure a storage account in Azure, then install the Umbraco extension for Azure Storage as a NuGet package and you're done. The NuGet installation script will automatically update your config files to make use of the new provider. Keep the old config around, as you might need it for local debugging of your Umbraco instance. I've chosen to simply include both config files and swap the right one in via a build task, depending on the environment.

Now all that's left is to put the actual data you already have in your Blob Storage. There's AzCopy, which simply let's you do this via a PowerShell cmdlet. I've also written a really small console app for this, which does the same and is a simple .NET Core dll executed with two arguments.

Umbraco Configuration & Deployment

There's little you have to do different regarding Umbraco's configuration and deployment strategy. When you've configured Azure SQL and Blob Storage, your website works as before.

However, there's one tip when hosting in Azure: To mitigate the really slow startup times for fresh deployments or app restarts, you might want to configure a staging slot with auto swap enabled and configure initialization actions to warm your site up before it's getting traffic. This means you'll no longer have to wait up to two minutes until your site responds to traffic!

 

If you're looking for options to automate your deployments, you can take a look at the NUKE build tool. It's open source, flexible and comes with lots of stuff built in - I use it literally everywhere.

 

Happy blogging!


Share this post


comments powered by Disqus

About me

Hi, my name's George! I love coding and blogging about it. I focus on all things around .Net, Web Development and DevOps.

DanglIT

Need a consultant for BIM, GAEB or Software Development?

Contact me at [email protected], +49 (173) 56 45 689 or visit my professional page!

Dangl.Blog();
// Just 💗 Coding

Social Links