One of the CMS that I’ve been working these days is EPiServer CMS developed in ASP.NET MVC and web Forms that offers many facilities to its development and implementation, including support Microsoft Azure.
In this post I will show you the steps needed to deploy it on Azure Web sites.
Install EPiServer CMS Visual Studio Extension
The first step is to install EPiServer CMS Visual Studio extension from TOOLS > Extensions and updates…
Looking for EPiServer in the search box and install it:
Create an EPiServer Web site project
The previous action required to reboot Visual Studio to use the new EPiServer templates. To create a new project we select New Project > EPiServer
In the next dialog box select the template that you want to use. This post will be used Alloy (MVC) which contains a sample site that will help us verify the CMS in Azure Web Sites.
Configure a new source and install EPiServer.Azure package
For a cloud solution of EPiServer on Azure Web Sites you must install the package EPiServer.Azure from Nuget. Before doing this is necessary to add a new source (http://nuget.episerver.com/feed/packages.svc) for EPiServer packages:
PM> Install-Package EPiServer.Azure
What services I need from Microsoft Azure services?
To work with EPiServer CMS you need a site in Azure Web sites, a database in SQL Database, a storage account in Azure Storage and messaging system in Service Bus. All can be created from https://manage.windowsazure.com/ using the NEW button from the bottom menu.
Within the web.config file we add the following code in the episerver.framework section, which will refer to our Storage and Service Bus accounts:
<blob defaultProvider="azureblobs"> <providers> <add name="azureblobs" type="EPiServer.Azure.Blobs.AzureBlobProvider,EPiServer.Azure" connectionStringName="EPiServerAzureBlobs" container="mysitemedia"/> </providers> </blob> <event defaultProvider="azureevents"> <providers> <add name="azureevents" type="EPiServer.Azure.Events.AzureEventProvider,EPiServer.Azure" connectionStringName="EPiServerAzureEvents" topic="MySiteEvents"/> </providers> </event>
Connection strings in the CONFIGURE section on Azure Web sites
Once we have created services within the platform, we must add the connection strings for each configuration within the website. We have two options: modify the web.config file or use the CONFIGURE section in Azure Websites on theAzure portal:
Connection strings that we use must be as key EPiServerDB (SQL Azure Database), EPiServerAzureBlobs (Azure Storage) EPiServerAzureEvents (Azure Service Bus). You can also add connection strings directly in the web.config file, but it would need to play with the changes in the file for the correct connections depending on the environment:
<connectionStrings> <add name="EPiServerDB" connectionString="Data Source=tcp:YOUR_SERVER.database.windows.net,1433;Initial Catalog=episerverdatabase;User Id=YOUR_USER@YOUR_SERVER;Password=YOUR_PASSWORD;Connection Timeout=60;Integrated Security=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> <add name="EPiServerAzureBlobs" connectionString="DefaultEndpointsProtocol=https;AccountName=YOUR_ACCOUNT_NAME;AccountKey=YOUR_ACCOUNT_KEY"/> <add name="EPiServerAzureEvents" connectionString="Endpoint=sb://YOUR_ACCOUNT_NAME.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=YOUR_ACCOUNT_KEY"/> </connectionStrings>
Deploy the solution on Microsoft Azure Web sites
The last step we must do is to deploy the solution to Azure Web sites. To do this right click on the project and select Publish…:
Select the website that we have created during the process and, the only value that must change is select the Update database checkbox and select the connection string that points to SQL Azure Database:
We click on the Configure database updates option, remove the check from [Auto schema update] and add the script located in the packages folder > EPiServer.CMS.Core.7.15.0 > tools called EPiServer.CMS.Core.sql (this script should only be used in the first deployment).
Publish the solution and confirm the site works correctly.
If It’s necessary make new deployments on the same web sites, you must select the Remove additional files at destination and unckeck Update database :
Hope this helps,
Cheers!