Sitecore Media Library integration with Azure CDN using origin pull

If your Sitecore website is heavy on content from the media library you can offload your Sitecore instances by allowing images to be retrieved from a Content Delivery Network (CDN). If you use Microsoft Azure, you do not need to upload images to the CDN, as Azure support origin pull.

Origin pull is a mechanism where the CDN automatically retrieves any missing content item from an origin host if the content is missing. In Azure, even parameters to the content is supported, so if you scale images with ?w=100, these parameters are supported, and the Azure CDN will store the scaled image.

To set up origin pull in Azure CDN, you first go to your CDN profile:

Azure CDN Profile

Azure CDN Profile

Then you click the + sign to add an endpoint:

Azure CDN Add Endpoint

Azure CDN Add Endpoint

And add an endpoint with the type “Custom Origin”:

Azure CDN Endpoint with Custom Origin

Azure CDN Endpoint with Custom Origin

The “name” is the name of the endpoint. The “Origin hostname” is the URL to your public Sitecore website. And remember to specify the correct protocol. If your website is running HTTPS, the CDN should use HTTPS as well.


The rest is configuration in Sitecore. You control the CDN properties using these settings, found in the Sitecore.config file:

<setting name="Media.MediaLinkServerUrl" value="" />
<setting name="Media.MediaLinkPrefix" value="-/media" />
<setting name="Media.AlwaysIncludeServerUrl" value="true" />
<setting name="MediaResponse.Cacheability" value="public" />
  • Media.MediaLinkServerUrl = The URL to the Azure CDN, as defined when creating the Azure Endpoint
  • Media.MediaLinkPrefix = The media library link URL. Together with the Media.MediaLinkServerUrl, the complete server URL is created. In the example, my url is library content]
  • Media.AlwaysIncludeServerUrl = Tells Sitecore to always include the server URL in the media requets
  • MediaResponse.Cacheability = Allows the cache settings of any item to be publicly available, allowing the Azure CDN to access the MaxAge, SlidingExpiration and VaryHeader parameters.


  • Your website needs to be public. When developing and testing you need to disable the CDN settings as the Azure CDN cannot read from a non-public website. Testing is therefore in production as the website runs.
  • Security settings on media library items cannot be used. Once a media library item is on the CDN it is public to everyone.




About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in Sitecore 8 and tagged , , , , , , , . Bookmark the permalink.

3 Responses to Sitecore Media Library integration with Azure CDN using origin pull

  1. commodore73 says:

    Thanks Brian. I’m not super familiar with Azure and especially PaaS. Did you try this with PaaS, or something else? If something else, any guess at equivalent steps for PaaS?


  2. briancaos says:

    It’s not tested on a PaaS solution, but I would be very surprised if it did not work on PaaS. Most of the work is done by the CDN. All I do is that I instruct Sitecore to prefix every Media Library URL with a different hostname/path, and to allow the cache settings to be publicly available.


  3. I usually use an internally available url for testing these CDN settings. It is of course not ideal as I am not testing the end CDN service, but at least I am able to test that the CDN url is set correctly on all static resources and Sitecore media resources when building and testing on test environment.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.