)

Deploying existing MVC projects to Azure Web Apps

If you already have a Kentico website hosted on a traditional web server or prepared for deployment, you can decide to move your project to Azure Web Apps.

This scenario assumes that you have a Kentico project installed on a local file system, connected to a standard Microsoft SQL database. To migrate your project to Azure, you need to:

  1. Create a deployment environment in Azure using Azure Resouce Manager
  2. Deploy the project's database to Azure SQL
  3. Publish the MVC and Kentico administration applications

Before you begin, please read the Pre-deployment checklist section first.

Pre-deployment checklist

The following is a list of issues you may encounter when deploying an existing project to Microsoft Azure. Assess whether they apply and adjust your project as recommended.

  • If your project uses manual web farms, the system may contain unnecessary web farm servers in the database. We recommend that you delete the old web farm servers in the administration interface (via the Web farm application) to ensure that a licensing error does not occur. Moreover, we strongly recommend switching to automatic web farms for the deployed project.
  • Your database may contain custom database objects that are not supported on Azure SQL. Because of this limitation of the Azure platform, you might not be able to migrate your database to Azure SQL without modifications. You might encounter issues when deploying your database to Azure if you have somehow customized your database (stored procedures, indexes, access to tables) or if you have developed custom modules.
On this page

Creating a deployment environment for MVC projects using Azure Resource Manager

Kentico provides an Azure Resource Manager (ARM) template that helps you deploy all Azure services and resources necessary to host your application in Microsoft Azure.

  1. Open Microsoft's Azure Quickstart Templates repository and search for Kentico MVC.
  2. Open the Kentico MVC environment template and click Deploy to Azure at the top of the page.
  3. Under basics, select your Azure subscription, resource group, and resource location.
  4. Under settings, provide the information required to deploy Azure services used to host your Kentico MVC site.
  5. Agree with the displayed terms and conditions and click Purchase.

The Azure Resource Manager deploys the two Web App instances and an Azure SQL server used to host your Kentico project in Azure. 

Deploying the project's database to Azure SQL

You can host your project in Azure Web Apps and keep your database in a standard Microsoft SQL server. However, we recommend that you also move your database to Azure to ensure the best performance:

  1. Open the Azure SQL server deployed by the template in the Azure portal.
  2. Click New database and:
    1. Specify the database name.
      • The database name should match the one you specified in the Connection String Database Name setting when deploying the ARM template. If you left the setting empty, you need to manually add database connection strings to the created Web Apps.
    2. Leave the Select source dropdown set to Blank database.
    3. Select a pricing tier.
    4. Set the database collation to the one used by your local database (Latin1_General_CI_AS by default).
  3. Click OK. 

Azure creates a new database under the SQL server. Continue with configuring the SQL server's firewall rules to allow connections to the server from your local environment:

  1. Open the SQL Server in the Azure portal.
  2. Switch to the Firewalls and virtual networks tab.
  3. Create a new access rule for the IP ranges of your development and administration machines.

Now you can deploy the project's SQL database to Azure. Please follow the instructions in the SQL Server database migration to SQL Database in the cloud article according to your requirements.

Publishing the MVC and Kentico administration applications to Azure

The last step in the deployment process is to publish the Kentico administration and MVC applications to the prepared Web App instances. This tutorial deploys both applications using the publishing wizard in Visual Studio.

Files excluded from projects

The publishing wizard only deploys files referenced in each application's .csproj file. If your project depends on any files not included in the solution (for example media library folders or files, script files, stylesheets, etc.), you need to add them using Visual Studio. 

To add files to a project, enable the Show All Files option in the Solution Explorer menu, locate the file, right-click the file and select Include in project

Publishing the Kentico administration application

Begin by publishing the Kentico administration project:

  1. Open the Kentico administration project's solution (WebApp.sln) in Visual Studio.
  2. Edit the CMSApp project's 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 session state data in an Azure environment.

  3. Right-click the CMSApp project in the Solution Explorer and select Publish....
  4. Select Microsoft Azure App Service and choose Select Existing.
  5. Click Publish.
  6. In the publishing wizard:
    1. Select your Azure subscription and the Resource group to which you deployed resources using the ARM template.
    2. Select the Web App created for the administration project.
    3. Click OK.
  7. Visual Studio downloads the publishing profile and deploys the Kentico administration project.

After the deployment has completed, perform the following configurations:

  1. Check that the project is correctly connected to the database (the database installation wizard does not appear).
  2. Add new licenses for both domains in the Licenses application.
  3. In the Sites application, set Site domain name to the domain of the Kentico adminstration Web App and Presentation Url to the full URL of the MVC Web App.

Publishing the MVC application

  1. Open the MVC project's solution in Visual Studio.
  2. Right-click the project in the Solution Explorer and select Publish....
  3. Select Microsoft Azure App Service and choose Select Existing.
  4. Click Publish.
  5. In the publishing wizard:
    1. Select your Azure subscription and the Resource group to which you deployed resources using the ARM template.
    2. Select the Web App created for the MVC project.
    3. Click OK.
  6. Visual Studio downloads the publishing profile and deploys the MVC project.

After the deployment of both applications has finished, perform the following final configurations:

Increasing storage capacity on Azure Web Apps

By default on Azure Web Apps, all files are stored in the file system with the application, including the media files. The capacity of the storage space is limited – the Basic plan has 10 GB storage available, see Websites Limits for details. When you exceed the capacity, for example by uploading large media files, you have the following options:

  • Raise the web hosting plan's pricing tier to Standard, which has 50 GB of storage. 
  • Configure your system to use Azure Blob Storage and store the media files there.

See Increasing storage capacity on Azure Web Apps for instructions.

Configuring web farms for Azure Web Apps

If you plan to increase the number of instances associated with your Web App service (on 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 Azure Web Apps for instructions.


Was this page helpful?