---
title: Configuring Azure CDN
---

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

A Content Delivery Network (CDN) can improve the performance of your websites running in the Azure environment. By replicating the files served by your project across multiple data centers around the world, Azure CDN can speed up delivery of static content, such as images or stylesheets, as well as streaming media. See [Getting started with Azure CDN](https://docs.microsoft.com/en-us/azure/cdn/cdn-create-new-endpoint) for details.

To start using a CDN for your project, you need to:

1. [Create a CDN service profile on the Azure Management Portal](#creating-a-new-azure-cdn-profile).
2. [Add CDN endpoints to the created profile](#adding-cdn-endpoints-to-the-azure-cdn-profile).
3. [Enable the CDN in Xperience](#configuring-xperience-to-use-a-cdn).

## Creating a new Azure CDN profile

1. Open the [Azure Management Portal](https://portal.azure.com/).
2. Click **Create a resource ->** **Web -> CDN -> Quick create**.
3. Fill in the CDN Profile
   1. Enter a name.
   2. Select a Subscription.
   3. Select a Resource Group or create a new one.
   4. Select a pricing tier.
4. Click **Create**.

## Adding CDN endpoints to the Azure CDN profile

1. Open the created Azure CDN profile.
2. On the Overview tab, click the **Endpoint** button. The Add an endpoint dialog window opens.
   1. Enter a name.
   2. Set the **Origin type** of the endpoint to **Storage**.
   3. Select the service from the **Origin hostname** drop-down list.
   4. (Optional) Set a custom path to the content you want distributed over the CDN.
   5. (Optional) Set a custom host header.
   6. Specify the protocol and port your service runs on (by default, all Azure services use the default HTTP and HTTPS ports)
3. Click **Add**.

> **Note:** Note that it may take up to 90 minutes for the new endpoint to propagate through the CDN network. You may receive error code 400 (Bad Request) errors during this time.

## Configuring Xperience to use a CDN

After you create a CDN using the management portal, you need to register the CDN in your Xperience project to start using this service.

1. Open the **web.config** file of your local project.
2. Add the **CMSAzurePublicContainer** and **CMSAzureCDNEndpoint** keys into the web.config file:

   ```xml

   <appSettings>
       <add key="CMSAzurePublicContainer" value="true" />
       <add key="CMSAzureCDNEndpoint" value="EndpointURL" />
   </appSettings>

   ```
3. Replace **EndpointURL** with the name of your created CDN endpoint – in the Azure Management Portal, open your Azure CDN profile and locate the hostname of the endpoint associated with your application\*\*.\*\*

   > **Note:** If your site runs under **HTTPS**, we recommend you always specify the **EndpointURL** using the **HTTPS** protocol.
   >
   > For example: **https://endpoint1.azureedge.net**
   >
   > Not doing so may result in [Mixed Content](https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content?hl=en) warnings being logged in your web browser's console when retrieving files from the CDN.
4. If your application is running in Azure, redeploy all changes made to the project.

Your project is now ready to use the created Azure CDN service.

## Azure CDN content caching

The expiration interval for Azure CDN cache can be defined by the following values:

1. By the **CMSAzureCDNCacheMinutes** web.config key.

   - See [Reference - Web.config application keys](https://docs.kentico.com/13/configuring-xperience/reference-web-config-application-keys.md#microsoft-azure-settings).
2. By the **Cache files (minutes)** setting in **Settings -> System -> Performance**.

   - See [Settings - Performance](https://docs.kentico.com/13/configuring-xperience/managing-sites/configuring-settings-for-sites/settings-system/settings-performance.md).
3. By the default value defined by Azure.

   - See the Azure documentation: [Manage expiration of Azure Storage blobs in Azure CDN](https://docs.microsoft.com/en-us/azure/cdn/cdn-manage-expiration-of-blob-content)

This list is ordered by priority, which means that the default Azure value can be overwritten by configuring the Cache files (minutes) key. And this setting can be overwritten by the _CMSAzureCDNCacheMinutes_ web.config key.

If you set the setting and the web.config key to 0 or an invalid value, the default Azure CDN value will be used.
