Migration of Kentico projects from Azure Cloud Services to Azure Web Apps

The scenario described on this page assumes that you have a Kentico Azure project running in Azure Cloud Services, connected to the Azure SQL server and Azure Blob Storage and you have access to the local development project. When you decide to migrate your project from Azure Cloud Services to Azure Web Apps, you need to create a new Web App service and transfer your configurations to the web.config file of your project. You can utilize the existing Azure SQL Database and Azure Blob Storage.

To migrate an Azure project from Cloud Services to Web Apps, you need to:

  1. Transfer configurations from the ServiceConfiguration.Cloud.cscfg file to the web.config file.
  2. Create a new Azure Web App service.
  3. Deploy the project as a web application through Visual Studio. Alternatively, you can also deploy your project over FTP.

Part 1 - Configuring Azure projects for Azure Web Apps

You can deploy only Kentico web site or web application projects to Azure Web Apps. Kentico projects installed as Azure projects contain a standard web application project in them. Therefore, you need to transfer configuration settings from the ServiceConfiguration.Cloud.cscfg file to the web.config file in the web application project and then deploy the web application project to Azure Web Apps.

  1. Open your Azure project in Visual Studio using the WebApp.sln file.

  2. Open the CMSApp\Web.config file.

  3. Add the CMSConnectionString key and value to the connectionStrings section of the web.config file.

         <add name="CMSConnectionString" connectionString="Data Source=tcp:YourServerName.database.windows.net,1433;Initial Catalog=YourDatabaseName;User Id=YourUsername@YourServerName;Password=YourPassword;" />
  4. Add the CMSAzureAccountName and CMSAzureSharedKey keys to the appSettings section of the web.config file.

         <add key="CMSAzureAccountName" value="StorageAccountName" />
         <add key="CMSAzureSharedKey" value="PrimaryAccessKey" />

    Replace StorageAccountName and PrimaryAccessKey with values from the ServiceConfiguration.Cloud.cscfg file.

  5. Configure the application to use Azure Blob storage according to the instructions in Configuring Azure storage.

    For Azure Web Apps deployments, we recommend mapping only media library folders to the Azure storage.

    In this scenario, you need to manually transfer any project files that exist on your Blob storage, but are not present in your local development project. Do not transfer your media library folders and the folders listed in Azure Web Apps problematic folders.

  6. Right-click the CMSApp project in the Solution Explorer and select Set as StartUp Project.

  7. Transfer any custom settings from the ServiceConfiguration.Cloud.cscfg file to the web.config file.

Your project is now ready to be deployed to Azure Web Apps, but first you need to create a new Azure Web App service.

Part 2 - Creating Azure Web Apps from Visual Studio

Before you can deploy your project, you need to create a new Azure Web App service. You can do this from the Microsoft Azure management portal or directly from Visual Studio:

In Microsoft Visual Studio 2012 and 2013, the service is still called Azure Websites.

  1. Open your Kentico project in Visual Studio via the WebApp.sln file.

  2. Open the Server Explorer tab (or Database Explorer tab in Express editions of Visual Studio).

  3. Right-click Azure, select Connect to Microsoft Azure Subscription and sign in to your Azure account.

  4. Expand the Azure node.

  5. Right-click App Service and select Create New App Service….

    1. On the Hosting tab, enter your web app name, select your subscription, Resource Group, and App Service Plan.
    2. On the Servicestab, create an SQL database for the application if necessary.
  6. Click Create.

    • The system creates a new Azure Web App.
  7. Right-click the newly created web app and select View settings.

  8. Modify the connection string to connect to your database deployed to an Azure SQL server (change the name of the database to correspond to your Azure SQL database).

You can view the newly created Azure Web App in the Azure management portal under Web Apps. The Web App service is now empty. You can now deploy your web application project to Azure Web Apps.

Automatically created Azure SQL Database

Note that creating a Web App from Visual Studio also creates a new Azure SQL Database on the specified server. If you already have a database on Azure, you will not need this automatically created database. Therefore, you should delete this database to avoid additional costs:

  1. Open the Azure management portal.
  2. Select SQL Databases.
  3. Select the automatically created database. The name should correspond to the name of the newly created Web App with a ’_db’ suffix.
  4. Click Delete.

Part 3 - Deploying Azure projects to Azure Web Apps

You are deploying your Azure project as a Kentico web application project.

  1. Open your Kentico project in Visual Studio via the WebApp.sln file.

  2. Open the web.config file and make sure that the sessionState mode is set to InProc.

     <sessionState mode="InProc" />

    Use InProc mode if you plan to use one instance of the Web App service. If you want to scale your web app to more instances, you will need to configure the session state differently. See Storing cache and session state data in Azure environment.

  3. Right-click the CMSApp project in the Solution Explorer and select Publish.

  4. Select Microsoft Azure App Service.

  5. Select the previously created web app in the drop-down list.

  6. Click OK. The system downloads the publish profile.

  7. Leave the settings as they are.

  8. Click Publish.

The system deploys your project to the Azure Web App service. Check that the project is correctly connected to the database (the database installation dialog does not appear).

Proceed to performing the following final configurations:

After that, your Kentico project is ready to run in Azure Web Apps.

Configuring web farms for Azure Web Apps

If you plan to increase the number of instances associated with your Web App service (via the Scale out (App Service plan) tab), you need to configure web farms in your project to dynamically create and delete web farm servers. See Enabling web farms on Windows Azure Web Apps for instructions.

Web farms are configured automatically for Cloud Services environment, however, they need to be enabled manually in Web Apps.