Use Sitecore Azure Toolkit to enable CDN for the Sitecore Media Library

Version: 10.4

This topic describes how to enable the Sitecore Media Library to use a Microsoft Azure® Content Delivery Network (CDN) using Sitecore Azure Toolkit. With a CDN you can set up the Sitecore Media Library to use a CDN on Azure. You can deploy a CDN by using Azure Marketplace or Sitecore Azure Toolkit.

Note

CDN is not available for on-premise deployments,  however, you can configure the Sitecore Media Library manually to use CDN.

Prerequisites

To enable the Sitecore Media Library to use a CDN with Azure Marketplace, you must have the following:

  • Sitecore XP and XM 9.1 or later.

  • A scaled configuration, (this option is only available for Azure deployments).

Using the Sitecore Azure Toolkit, you can deploy a new Sitecore environment to the Microsoft Azure App Service® with a CDN. This module is only supported in the XP Scaled and XM Scaled configurations of a Sitecore environment

Considerations for setting up a CDN

You can set up a CDN with either of the following scenarios:

  • You do not have a CDN, and you want Sitecore create one.

  • You have already set up a CDN endpoint, and you want to direct Sitecore to use it.

You do not have a CDN, and you want Sitecore to create one

There is no preparation required for this scenario. However, you must choose from the available Azure CDN pricing tiers. For more information about creating a CDN profile and endpoint configurations from Sitecore, see: CDN setup Considerations, the section CDN setup Considerations when Sitecore sets up CDN for you.

You have already set up a CDN endpoint, and you want to direct Sitecore to use it

If you have already set up a CDN endpoint, you can share the URL of the endpoint during deployment. Before following the setup steps, read CDN setup considerations.

Deploying by using Sitecore Azure Toolkit

Using the Sitecore Azure Toolkit, you can deploy a new Sitecore environment to the Microsoft Azure App Service® with a CDN. This module is only supported in the XP Scaled and XM Scaled configurations of a Sitecore environment.

To configure an environment template for deploying with CDN, work through the following:

  1. Update the azuredeploy.json file by adding the CDN configuration to the to the modules properties. For more information about adding modules, see: , specifically the Add modules section.

    Note

    The Sitecore Quickstart templates (for example the azuredeploy.parameters.json file, are available on GitHub.

  2. To add CDN modules, add the following code the modules parameter, and refer to the parameters for CDN in the CDN folder on Github.

    RequestResponse
    {
        "name": "cdn",
        "templateLink": "<Link to CDN module armtemplate>",
        "parameters": {
            "templateLinkAccessToken": "<Optional[string], query string of access token. Default: "">",
            "hasCdnProvider" : "<Optional[boolean], set to true if has existing CDN Service. Default: false>",
            "cdnSKU" : "<Required[string], CDN Profile SKU when 'hasCdnProvider' property is set to false, default: "Standard_Akamai">",
            "mediaLinkServerUrl" : "<Required[string], CDN Service endpoint url when 'hasCdnProvider' property is set to true, default: "">",
            "mediaMaxAge" : "<Optional[string], media item max age. Default: "7.00:00:00">",
            "cdnMsDeployPackageUrl" : "<Required[string], URL of the CDN WDP file *.scwdp.zip>"
        }
    }
    
  3. Add the Bootloader module.

  4. Run the deployment command.

Note

Some of the pricing tiers may need setting up, post-deployment. If so, refer to the Control Azure CDN caching behavior with query strings - Premium tier.

Verifying configurations

To verify your configurations, check:

  • The Sitecore configuration page - On the Sitecore CD server, go to /sitecore/admin/showconfig.aspx. All of the configurations mentioned in the above steps must come from the CDN.config patch file that you created.

  • Any URL that has been created using one of the options mentioned in Developer considerations for the Sitecore Media Library CDN support, in the section: Getting a CDN-enabled Media Item URL. Ensure the generated URL includes a CDN URL and revision number.

Do you have some feedback for us?

If you have suggestions for improving this article,