Office 365 CDN - Preview vs General Availability

Office 365 CDN - Preview vs General Availability

[Srinivas Varukala]( Varukala) 5/24/2017 4:06:00 PM

Office 365 CDN which provides a way to configure a SharePoint Document Library as a CDN is now Generally Available. The preview was released few months back and if customers already using it while in Preview must know that the PowerShell commands and the way this works has changed a lot in General Availability. With GA, we now have a public CDN and a private CDN. Note that Private CDN is in Preview. The main point to note is that the CDN URL generator /_vti_bin/publiccdn.ashx is not working anymore. This essentially means do not use it, update your URLs with the GA api. Preview vs General Availability


General Availability


Enable CDN (Tenant level setting)

Set-SPOTenant -PublicCdnEnabled $true  

#NOTE: Public CDN is GA. Private CDN is in preview. Set-SPOTenantCdnEnabled -CdnType Public   #-NoDefaultOrigins Set-SPOTenantCdnEnabled -CdnType Private #-NoDefaultOrigins #Alternatively enable both using below cmdlet #Set-SPOTenantCdnEnabled -CdnType Both

Verify CDN Enabled

Get-SPOTenant | FL \*cdn\*  

Get-SPOTenantCdnEnabled -CdnType Public Get-SPOTenantCdnEnabled -CdnType Private

Get CDN Policies

Get-SPOTenant | Select PublicCdnAllowedFileTypes  

Get-SPOTenantCdnPolicies -CdnType Private Get-SPOTenantCdnPolicies -CdnType Public

Set CDN Policy

Set-SPOTenant -PublicCdnAllowedFileTypes "CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,TXT"  

Set-SPOTenantCdnPolicy -PolicyType {IncludeFileExtensions | ExcludeRestrictedSiteClassifications | ExcludeIfNoScriptDisabled} -PolicyValue [string] -CdnType {Public | Private}

New CDN Origin

New-SPOPublicCdnOrigin -Url ""  

Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl sites/dev/cdnlib Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/pub/cdnlib Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl \*/imageassets Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl \*/photos

Get CDN Origins


Get-SPOTenantCdnOrigins -CdnType Public Get-SPOTenantCdnOrigins -CdnType Private

Remove CDN Origins

Remove-SPOPublicCdnOrigin -Identity 193700617159…  

Remove-SPOTenantCdnOrigin -CdnType Public -OriginUrl sites/dev/cdnlib Remove-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/pub/cdnlib

CDN Url Structure[tenant host name1130bbbb93becf13dd9ec288398ef3f53a8dd131d7f1116f9d3f0b89a5277b45/[ID of the public CDN origin]/[sub-path under the origin]   E.g: /159..e352d/jigsaw.jpg[tenant host name]/sites/site/library E.g:\_eat\_=1495567990\_1130bbbb93becf13dd9ec288398ef3f53a8dd131d7f1116f9d3f0b89a5277b45 &_oat_=1495567990_de85e8d775578ba993690038577140247188eb5a69c7855ffffb89d5f8525519”  

Generate CDN Url\_vti\_bin/publiccdn.ashx/ url?itemurl= sites/Dev/SiteAssets/Photos/jigsaw.jpg NOTE: This CDN Url generator is not working anymore since the GA. I am assuming this is to discourage using the Preview api. I will update this as I learn more about it. See Vesa’s note here.\_vti\_bin/publiccdn.ashx/url?itemurl=https://  

CDN URL Validation in Fiddler

Add header “Referer:” to the GET request

Auto-Rewrite of URls

Not Applicable

Only in GA

Connect-SPOService []( ###GENERAL AVAILABILITY API###### Get-SPOTenantCdnEnabled \-CdnType  Public Get-SPOTenantCdnEnabled \-CdnType  Private Set-SPOTenantCdnEnabled \-CdnType  Public #-NoDefaultOrigins Set-SPOTenantCdnEnabled \-CdnType  Private  #-NoDefaultOrigins #Set-SPOTenantCdnEnabled -CdnType Both   Get-SPOTenantCdnPolicies \-CdnType  Public Get-SPOTenantCdnPolicies \-CdnType  Private Set-SPOTenantCdnPolicy \-PolicyType {IncludeFileExtensions  |  ExcludeRestrictedSiteClassifications  |  ExcludeIfNoScriptDisabled} \-PolicyValue  [string]  \-CdnType     {Public  |  Private}  Add-SPOTenantCdnOrigin \-CdnType  Public  \-OriginUrl  sites/dev/cdnrepo Add-SPOTenantCdnOrigin \-CdnType  Private  \-OriginUrl  sites/pub/cdnlib Add-SPOTenantCdnOrigin \-CdnType  Public  \-OriginUrl  \*/imageassets Add-SPOTenantCdnOrigin \-CdnType  Public  \-OriginUrl  \*/photos  Get-SPOTenantCdnOrigins \-CdnType  Public Get-SPOTenantCdnOrigins \-CdnType  Private  Remove-SPOTenantCdnOrigin \-CdnType  Public  \-OriginUrl  sites/dev/cdnlib Remove-SPOTenantCdnOrigin \-CdnType  Private  \-OriginUrl  sites/pub/cdnlib Set-SPOTenantCdnEnabled \-CdnType  Both  \-Enable  $false #GA SAMPLES URL FORMAT: [[tenant]( host  name]/sites/site/library []( []( []( []( [\_eat\_=1495567990\_1130bbbb93becf13dd9ec288398ef3f53a8dd131d7f1116f9d3f0b89a5277b45&\_oat\_=1495567990\_de85e8d775578ba993690038577140247188eb5a69c7855ffffb89d5f8525519]( []( ###PREVIEW API######## Get-SPOTenant |  FL  \*cdn\* Set-SPOTenant \-PublicCdnEnabled  $true Get-SPOTenant |  Select  PublicCdnAllowedFileTypes Set-SPOTenant \-PublicCdnAllowedFileTypes  "CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF,TXT" New-SPOPublicCdnOrigin \-Url  "[](" Get-SPOPublicCdnOrigins Remove-SPOPublicCdnOrigin \-Identity  1937006161eeae8fe7159… #PREVIEW SAMPLES URL FORMAT: [[tenant]( host  name]/[ID  of  the  public  CDN  origin]/[sub-path  under  the  origin] []( []( [\_vti\_bin/publiccdn.ashx/url?itemurl=](

How does image renditions work in combination with the Office 365 CDN:

SharePoint Online and 2013/2016, it supports image renditions. Image renditions are configured using the Site Settings ] Look & Feel ] Image Renditions page. Example entry: RenditionID: 8, Width: 200, Height: 400 Image renditions are used by appending the renditionid to the image url. For example: This same approach is not supported with the images in a CDN enabled library. That means if you append RenditionID to CDN url (example:, its not honored. Image Renditions for CDN images can be achieved much more easily by just appending the width and height to the CDN Url. Example:

  • Image rendition support for images from the CDN can be enabled with height and width query parameters in the URL
    • Note. both height and width parameters are required for the renditions to work
    • You can also control the cropMode for the images with cropMode query parameter with following options: fit, fill, top and bottom (fit is default value).
  • You can use renditions with query parameters for the image URL

About the author

I work with customers helping them achieve more using Microsoft Technologies. I am in my 9th year with Microsoft as of March 2020. I get to work with really smart people (both at Microsoft and Customers). Helping customers, removing any blockers, rapid prototyping is my core work.