Deploying to Azure Web Apps

Microsoft Azure Web Apps is a service which allows you to create and host websites in the cloud. By deploying your project to Azure, you can leverage additional features and services such as security, load balancing, auto-scaling, and automated management.

To host your project on Azure, you need to:

  1. Create a deployment environment in Azure using Azure Resource Manager
  2. Deploy the project’s database to Azure SQL
  3. Publish the Xperience administration and live site applications to Azure

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.

Creating a deployment environment using Azure Resource Manager

Xperience 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 Xperience.

  2. Open the Kentico Xperience template and click Deploy to Azure at the top of the page.

  3. Select your Azure subscription, resource group, and resource location.

  4. Provide the information required to deploy Azure services used to host your environment.

    Select a Basic or higher pricing tier for each App Service hosting plan. The Free and Shared hosting plans do not provide enough memory to run an Xperience application.

  5. Click Review + create and finish the template deployment.

The Azure Resource Manager deploys the two Web App instances and an Azure SQL server used to host your Xperience 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.

        Configuring the connection string after deployment

        You can also configure the connection string through the Azure Management Portal in App Services -> select a web app -> Application settings -> Connection strings section. Add the connection strings in the following format:

        • Name: CMSConnectionString
        • Value: Data Source=tcp:<SQL_SERVER_NAME>,1433;Initial Catalog=<DATABASE_NAME>;User Id=<USER_NAME>@<SQL_SERVER_NAME>;Password=<USER_PASSWORD>;
        • Type: SQLServerReplace <SQL_SERVER_NAME><DATABASE_NAME><USER_NAME>, and <USER_PASSWORD> with the values you provided during the ARM template deployment.
    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 networkstab.
  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.

Database server time zones

If possible, use the same time zone for both your local environment and the Azure SQL server. Otherwise you may encounter time shift problems with the deployed data, for example in the settings of scheduled tasks.

See: Changing the server time zone on Azure Web Apps

If you cannot synchronize the time zones, we recommend that you verify and reconfigure the timing settings of scheduled tasks after the deployment.

Publishing the Xperience administration and live site applications to Azure

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

Before you publish both applications:

  • Edit both 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 each Web App. However, if you need to scale out to more instances, you will need to configure the session state differently. See Storing session state data in an Azure environment.

  • 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 Scaling Azure Web Apps for more information.

  • If you wish to precompile the Xperience administration application before or during your deployment process, you need to store the system’s virtual objects in the project’s CMSVirtualFiles folder on the file system (enable deployment mode in Xperience). See Precompiling websites.

  • 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 and files, administration virtual object files, scripts, stylesheets, etc.), you need to add them using Visual Studio. 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 Xperience administration application

Begin by publishing the Xperience administration project:

  1. Open the Xperience administration project’s solution (WebApp.sln) in Visual Studio.
  2. Right-click the CMSApp 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 administration project.
    3. Click OK.
  6. Visual Studio downloads the publishing profile and deploys the Xperience administration project.

After the deployment has completed:

  1. Check that the project is correctly connected to the database (the database installation wizard does not appear).
  2. Add a new licenses for both domains in the License keys application.
  3. In the Sites application, set Administration domain name to the domain of the administration Web App and Presentation Url to the full URL of the live site Web App.
  4. If your administration project is precompiled, make sure that deployment mode is enabled. For example, this may be necessary if you do not deploy your local database together with the project. See Deployment mode for administration virtual objects for details.

Publishing the live site application

  1. Open the live site 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 live site project.
    3. Click OK.
  6. Visual Studio downloads the publishing profile and deploys the live site project.

After the deployment of both applications has finished:

Post-deployment scenarios

Using separate deployment slots

When deploying your Web Apps to Azure App Service, you can Set up staging environments by using a separate deployment slot instead of the default production slot. However, the production and staging deployments use the same machine name, which prevents the Xperience web farm synchronization from working correctly in automatic mode due to non-unique server names. This can lead to issues with unsynchronized files or delayed application of changes due to uncleared cached data.

If you use staging deployment slots, we strongly recommend that you ensure unique server names for the web farm servers on all environments. Set one of the following configuration keys (Application settings) for your deployments:

  • Specify a custom suffix for every deployment slot server name via the CMSInstanceNameSuffix key.
    – OR –
  • Override the automatic server name completely via the CMSWebFarmServerName key.

Increasing the storage capacity of deployed Web Apps

By default on Azure Web Apps, all files are stored in the file system with the application. If you need to increase your storage capacity, you have the following options:

  • Raise the Web App’s hosting plan tier, which increases the available storage capacity.
  • Set up a separate Azure Blob Storage account and store select files there. For example, we recommend storing folders containing media library files, form attachments, or other folders likely to grow in size due to visitor contribution or content editor activity.

Storing specific files on Azure Blob Storage

  1. Proceed according to Mapping files to Azure storage.
  2. Re-deploy your project.

Links will be different for files in the file system and files located on the Blob Storage. Files that existed before the switch to blob storage remain stored in their original location.

Everything else apart from the mapped files will be stored on the Web App’s file system.

Troubleshooting email sending

Depending on your Azure subscription type and the configured SMTP server, you may encounter issues with emails not being sent from Xperience when hosted on Azure. This may be caused by SMTP connection restrictions on the side of Azure.

To resolve such issues, read and follow the recommendations in the Troubleshoot outbound SMTP connectivity problems in Azure article.