---
title: Setting up Kentico in Azure Web Apps
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The following scenarios describe how to create a new Kentico website as an Azure Web Apps service. You have the following options:

- [Using Azure Resource Manager and Visual Studio](#deploying-mvc-projects-using-azure-resource-manager-and-visual-studio) (MVC projects only)
- [Using Visual Studio](#deploying-kentico-projects-from-visual-studio) (both MVC and Portal Engine projects)
- See other options for [deploying Kentico to Azure Web Apps in the Microsoft documentation](https://docs.microsoft.com/en-us/azure/app-service/deploy-ftp)

## Deploying MVC projects using Azure Resource Manager and Visual Studio

Kentico provides an [Azure Resource Manager](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-overview) (ARM) template that helps you deploy all Azure services and resources necessary to host you application in Microsoft Azure.

1. Open Microsoft's [Azure Quickstart Templates](https://azure.microsoft.com/en-us/resources/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 MVC site.
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 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](https://portal.azure.com).
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_ drop-down set to _Blank database_.
   3. Select a [pricing tier](https://azure.microsoft.com/en-us/pricing/details/sql-database/managed/).
   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](https://portal.azure.com).
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](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-cloud-migrate) article according to your requirements.

> **Note:** **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](https://docs.kentico.com/k12sp/configuring-kentico/scheduling-tasks.md).
>
> See:  [Changing the server time zone on Azure Web Apps](https://blogs.msdn.microsoft.com/tomholl/2015/04/06/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 Kentico administration and MVC 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.

> **Note:** **Before you publish**
>
> If you wish to **precompile** the Kentico 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 Kentico). See [Publishing projects from Visual Studio](https://docs.kentico.com/k12sp/deploying-websites/publishing-projects-from-visual-studio.md).
>
> 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**.

#### 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**.

   ```xml

   <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](https://docs.kentico.com/k12sp/deploying-websites/running-kentico-on-microsoft-azure/storing-session-state-data-in-an-azure-environment.md).
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 a 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.
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 virtual objects](https://docs.kentico.com/k12sp/deploying-websites/deployment-mode-for-virtual-objects.md) for details.

Now publish the MVC application following a similar process:

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:

- Make sure your live site and administration Web Apps are configured to use the same server time zone. See  [Changing the server time zone on Azure Web Apps](https://blogs.msdn.microsoft.com/tomholl/2015/04/06/changing-the-server-time-zone-on-azure-web-apps/) .

## Deploying Kentico projects from Visual Studio

This scenario presumes that you already have a Kentico project installed on a local computer and you want to deploy it to an Azure Web App service using Visual Studio. You can also create the Web App service directly from Visual Studio.

> **Note:** **Deploying MVC sites**
>
> For sites created using the [MVC development model](https://docs.kentico.com/k12sp/developing-websites/mvc-development-overview.md), you need to perform the deployment process for **both** the MVC live site project and the Kentico administration project (using a separate Web App service for each project). However, the database is shared – only create the database once and then use the same connection string in both projects.

1. Open your project in Visual Studio.
2. Open the **Server Explorer**.
3. Expand the **Azure** section, right-click **App Service**, and select **Create New App Service...**

   - The **Create App Service** dialog opens.
4. Enter the web app name (the resulting URL of your application).
5. Select the Azure subscription under which the Web App will be created.
6. Select an existing Resource Group or create a new one.
7. Select an existing Hosting plan or create a new one.

   > **Tip:** For MVC sites, we strongly recommend using two different hosting plans – one for the MVC live site application and another for the Kentico administration application. This allows you to scale the applications independently. In most cases, the MVC live site will receive the bulk of the traffic and have different performance requirements than the administration interface.

   ![Creating an App Service in Visual Studio 2017](https://docs.kentico.com/docsassets/k12sp/setting-up-kentico-in-azure-web-apps/CreateAppServiceDatabaseIncluded.png "Creating an App Service in Visual Studio 2017")
8. Click **Create a new SQL Database** and create a new database for the application.
   1. Enter the name of the database.
   2. Select an existing or create a new SQL server.
   3. Provide administrator credentials for the server.
   4. Set the **Connection String Name** field to _CMSConnectionString_.
   5. Click **OK**.

      ![Creating a new SQL Database](https://docs.kentico.com/docsassets/k12sp/setting-up-kentico-in-azure-web-apps/ConfigureSqlDatabase.png "Creating a new SQL Database")
9. Back in the main dialog window, click **Create**.

Visual Studio creates the App Service. Continue by adjusting your project's _web.config_ file:

1. Right-click the created web app (you might need to refresh the App Service section for the app to appear) and select **View settings**.
2. Copy the connection string value and paste it to the **web.config** file of your project.

   ```xml

   <connectionStrings>
       <add name="CMSConnectionString" connectionString="Data Source=tcp:YourServerName.database.windows.net,1433;Initial Catalog=YourDatabaseName;User Id=YourUsername@YourServerName;Password=YourPassword;" />
   </connectionStrings>

   ```

   Replace **YourServerName**, **YourDatabaseName**, **YourUsername** and **YourPassword** with your own values.

   > **Tip:** **Configuring the connection string after deployment**
   >
   > You can also configure the connection string through the [Azure Management Portal](https://portal.azure.com/) in **App Services ->** select a web app **-> Application settings -> Connection strings** section. To set the connection string for the web app, change the _defaultConnection_ name to _CMSConnectionString_.
3. Make sure that the sessionState mode is set to **InProc** in the web.config file.

   ```xml

   <sessionState mode="InProc" />

   ```

   Use _InProc_ mode if you plan to use only one instance of the Web App service. If you want to scale your web app to more instances, you need to configure the session state differently. See [Storing session state data in an Azure environment](https://docs.kentico.com/k12sp/deploying-websites/running-kentico-on-microsoft-azure/storing-session-state-data-in-an-azure-environment.md).

You are now ready to deploy the project:

1. Right-click the project in the Solution Explorer and select **Publish** (or **Publish Web App**).

   - A **Publish** dialog opens.
2. Click **Microsoft Azure App Service**.
3. Select the created web app located under the resource group you specified.
4. Click **OK**.
5. Do not modify the default settings.

   ![Publishing the Web App](https://docs.kentico.com/docsassets/k12sp/setting-up-kentico-in-azure-web-apps/Publish.png "Publishing the Web App")
6. Click **Publish**.
7. Once the publishing process is finished, Visual Studio automatically opens the base URL of your project in your default browser. Follow the on screen wizard to complete the database installation.

Once everything is set up, we recommend you perform the following configuration:

- [Adjust the web hosting plan mode](https://docs.kentico.com/k12sp/deploying-websites/running-kentico-on-microsoft-azure/running-kentico-in-azure-web-apps/adjusting-the-web-hosting-plan-mode-on-azure-web-apps.md) on your web app.
- Configure the tier of your Azure SQL database according to our [recommendations](https://docs.kentico.com/k12sp/deploying-websites/running-kentico-on-microsoft-azure/recommendations-on-using-azure-sql-database-tiers.md).
- For MVC sites, make sure your live site and administration apps are configured to use the same server time zone. See [Changing the server time zone on Azure Web Apps](https://blogs.msdn.microsoft.com/tomholl/2015/04/06/changing-the-server-time-zone-on-azure-web-apps/).
