Migrating & Deploying Telerik’s Sitefinity CMS to Windows Azure

So I started to migrate Telerik’s Sitefinity CMS to Windows Azure this weekend and based on all the documentation out there…, well let’s just say it wasn’t as comprehensive as I thought it should be; hence this blog post for others that may need some supplementary guidance with http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/deployment/deploying-sitefinity-projects-to-windows-azure/.

I’ll keep this in Azure for as long as I can, mean while here’s the Url of the sample Sitefinitity instance that was deployed to Azure in this blog post: http://sitefinityinazure.cloudapp.net.

Note: Throughout this process you can debug, build, however do not perform a clean or rebuild on the solution. The Sitefinity assemblies are included and referenced from the bin folder, performing a clean or rebuild will wipe these assemblies out unless you copy them out of the bin folder into another folder (e.g. folder named “Assemblies”) and re-reference them. This is a known issue when doing a clean or rebuild http://www.sitefinity.com/devnet/kb/sitefinity-4-x/an-error-%E2%80%9Ccould-not-load-file-or-assembly-telerik-sitefinity-migrationcontracts-or-one-of-its-dependencies-%E2%80%9D-is-thrown-when-you-rebuild-or-clean-your-sitefinity-4-2-project.aspx. If time permits I will post another blog for this solution.

For the purpose of what actually works, we will stick with the sequence of these steps:

  1. Start with a fresh install and instance of a Sitefinity site
  2. Create a test page, with a content widget
  3. Create the SQL Azure Instance
  4. Create the SQL Azure Blob Storage
  5. Migrate the local database to SQL Azure and assert that the application runs fine locally using the SQL Azure instance in the cloud
  6. Configure the Azure Blob storage
  7. Add and configure the Azure Web Role to the solution and confirm that it works locally with the Azure emulators, this installs with Azure SDK (optional step)
  8. Deploy our Sitefinity instance into Windows Azure as a Cloud Service, we will provision the Cloud Service as part of the first time deployment to Azure

So let’s start with our Sitefinity instance, for the purpose of this post I’ve created a new Sitefinity instance (with the Community license) and named it SitefinityInAzure running on a local SQL2008R2 database instance. Database name will also be named the same as the Sitefinity site name, SitefinityInAzure. I would highly recommend you practice this migration on a fresh new blank site rather than on actual production site until you get the hang of things.

Start off by making sure your local instance of Sitefinity is golden, we can do this by spinning up Sitefinity Project Manager and browse to Admin area by clicking [Go To Administration] on the context menu.

Do a quick sanity check and validate that everything on the Administration is golden.

Go ahead and create a test page. This can be done by going to Pages > Create New Page > Save > Publish.

View the page.

Now let’s start the database migration first, first in order is to create and setup an instance of SQL Azure.

Go ahead and copy the connection string so that we can use this in a bit.

Launch your Sitefinity instance with Visual Studio.

Open up the DataConfig.config file, where Sitefinity’s connection string is stored and let’s go ahead and modify it to use SQL Azure.

Before:


<?xml version="1.0" encoding="utf-8"?>
<dataConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="5.1.3270.0" initialized="True">
	<connectionStrings>
		<add connectionString="data source=localhost;Integrated Security=SSPI;initial catalog=SitefinityInAzure" providerName="System.Data.SqlClient" dbType="MsSql" name="Sitefinity" />
	</connectionStrings>
	<urlEvaluators>
		<add description="ForumsEvaluatorDescription" resourceClassId="ForumsResources" type="Telerik.Sitefinity.Forums.Web.ForumsEvaluator" enabled="True" name="Forums" />
	</urlEvaluators>
</dataConfig>

After (note the dbType attribute has been set to SqlAzure):


<?xml version="1.0" encoding="utf-8"?>
<dataConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="5.1.3270.0" initialized="True">
	<connectionStrings>
		<add connectionString="data source=[your-azure-servername-goes-here].database.windows.net;initial catalog=SitefinityInAzure; User ID=[your-azure-username-for-sqlazure]; Password=[your-password-for-sqlazure-goes-here]" providerName="System.Data.SqlClient" dbType="SqlAzure" name="Sitefinity" />
	</connectionStrings>
	<urlEvaluators>
		<add description="ForumsEvaluatorDescription" resourceClassId="ForumsResources" type="Telerik.Sitefinity.Forums.Web.ForumsEvaluator" enabled="True" name="Forums" />
	</urlEvaluators>
</dataConfig>

Update your web.config for Azure configuration, first uncomment the sectionGroup with name Telerik.

Before:


  <configSections>
    <section requirePermission="false" name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <!--<sectionGroup name="telerik">
      <section name="sitefinity" type="Telerik.Sitefinity.Configuration.SectionHandler, Telerik.Sitefinity" requirePermission="false" />
    </sectionGroup>-->
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

After:


  <configSections>
    <section requirePermission="false" name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <sectionGroup name="telerik">
      <section name="sitefinity" type="Telerik.Sitefinity.Configuration.SectionHandler, Telerik.Sitefinity" requirePermission="false" />
    </sectionGroup>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>


Uncomment the Telerik section (towards the end of the web.config file).

Before:


  <!-- Begin telerik section  -->
  <!--<telerik>
    <sitefinity>
      <environment platform="WindowsAzure"/>
      <sitefinityConfig storageMode="Database" />
    </sitefinity>
  </telerik>-->
  <!-- End telerik section  -->


After:


  <!-- Begin telerik section  -->
  <telerik>
    <sitefinity>
      <environment platform="WindowsAzure"/>
      <sitefinityConfig storageMode="Database" />
    </sitefinity>
  </telerik>
  <!-- End telerik section  -->
</configuration>

Now that our Sitefinity app is ready to work with SQL Azure, let’s migrate our actual data first. For this you will need to download SQL Azure Migration Wizard (http://sqlazuremw.codeplex.com/).

Launch an instance of SQL Azure Migration Wizard and select: Analyze / Migrate – SQL Database option and click next.

Select the current SitefinityInAzure local database that you be migrating from (source).

Generate the SQL Script (that SQL Azure Migration Wizard will use to execute on the target SQL Azure Instance, that we created earlier).

Great now let’s run our local instance of SitefinityInAzure and verify that our on-premise app is working with our off-premise SQL Azure instance where we just migrated our data too. We can do this by browsing to the Administration page.

Great, we are half way there now. All we have left is getting our application Azure ready and deployed to Azure.

Let’s start off by making sure that all the required assemblies will be deployed in the Azure by expanding the references folder and checking that all the required assemblies to be deployed to Azure by setting the “Copy Local” to true.

Be default all of the required assemblies should already have the property “Copy Local” set to true set already, so there should not be any work here required besides a quick check, this step can be skipped.

This should be done for all references with the exception of:

  • System.Windows
  • Microsoft.WindowsAzure.ServiceRuntime
  • MySql.Data
  • Telerik.OpenAccess.MySql.Data
  • Interop.DexterLib

Now let’s go ahead and add our Azure Web Role to our solution, right click the Solution and add a Windows Azure Cloud Service project from VS templates and give it a name SitefinityWebRole.

When prompted for what type of role you would like to include, DO NOT SELECT ANY OPTION (the right side selected list box should be blank), we will manually add this in the next step, click OK.

Now with the context menu of the SitefinityWebRole Roles folder click “Web Role Project in solution” and choose SitefinityWebApp as the project to be added as the WebRole.

Let’s go ahead and create a blob storage in Azure so that Sitefinity will have a place to log to, go ahead and name the Blog Storage: sitefinityinazure.

Copy the primary access key for you Azure Blob Storage.

Let’s go ahead and configure the new SitefinityWebRole by go the properties of the newly added Role (click on the properties of the context menu of SitefinityWebRole/Roles/SitefinityWebApp).

Configuration, make sure the Service Configuration “Cloud” is selected.

Endpoints

Local Storage

Registry, the last thing we need to do is reorder some permissions, or you may get the an exception with the Azure runtime starts up in debug mode. Browse to HKLM/Software/Microsoft/Windows Azure with Regedt32, you will get a prompt that this action will Re-Order your permissions click OK, and on the next screen click Apply then OK. Do the same for the HKLM/Software/Microsoft/Windows Azure Emulator.

The WebRole configuration is now complete, now before deploying anything, let’s validate that everything works fine locally with the Azure SDK and the Azure Emulators by hitting F5 or clicking the debug button within Visual Studio.

If you get this prompt to modify your web.config for debugging, go ahead and click OK.

You should see the Windows Azure Debugging Environment spin up (this could take a minute or two).

We should see the “About Us” test page we created earlier running on our locally on our Windows Emulators.

Now, let’s deploy to Azure!

You can skip this step, however I went ahead and configured this so that I could RDP into this instance.

Click on Publish, this could take a while since you are also provisioning your WebRole service for the first time as well as deploying. Once completed you should see this area in your Windows Azure Activity Log.

Click on the Website Url link.

I will leave the Windows Azure resources/instances that were created for the purposes of this blog for as long as I can, until then you can view the actual Sitefinity instance that was used to deploy in Azure at this Url: http://sitefinityinazure.cloudapp.net.

Made a few changes to the content on the “About Us” page we created earlier just to excercise some of Sitefinity’s CMS abilities 😉

Log-in to the back end (don’t want to state the obvious here, however our Url is http://sitefinityinazure.cloudapp.net/Sitefinity/Dashboard, in Azure).

Sitefinity has been migrated and deployed into Windows Azure!

One last note that I thought was interesting, was how easy it is connecting with RDP to your Azure Cloud Service instance.

Log in to the RDP session with your server credentials you used when deploying.

Happy CMS’ing..! 🙂

One thought on “Migrating & Deploying Telerik’s Sitefinity CMS to Windows Azure

  1. Long,

    I tried following your instructions but at the very end when trying to publish sitefinity i get an out of memory error.

    Any chance you know what that is?

    Like

Comments are closed.