Office 365 Public CDN Developer Preview Release

Vesa Juvonen

We are happy to announce availability of Office 365 Public Content Delivery Network (CDN) capability in the Office 365. This capability will enable you to automatically host static assets, like images and JavaScript files in CDN for providing better performance with SharePoint pages. CDN will work effectively as a geo-distributed caching proxy, by caching the static assets closer to the browsers requesting them.

Office 365 Public CDN is now released as a Developer Preview for all tenants in Office 365. You can start using it by explicitly enabling the capability on the tenant level using PowerShell cmdlets.

Following picture clarifies the logical flow of using Office 365 Public CDN.

Logical flow of Office 365 Public CDN

  1. Administrator enables Office 365 Public CDN for the tenant using SharePoint Online Management Shell.
    • Cmdlets allow to designate certain SharePoint document libraries or folders to serve as a CDN origin. Note, that assets exposed via Public CDN are accessible by everyone anonymously. Therefore, resources that are considered sensitive by the company should never be placed in those libraries.
    • Cmdlets also provide capability to choose the file types exposed via CDN. By default, common design asset types are enabled.
  2. Static assets to be shared via CDN are being uploaded to the SharePoint libraries or folders, which are enabled as the CDN origins.
  3. Assets are being exposed from the configured libraries of folders and they can be accessed using the CDN URLs.
  4. URLs pointing to CDN location are available to be used in the SharePoint sites and in the customizations hosted from SharePoint.

In case the asset is updated in the SharePoint library, the new version will become available via CDN within 15 minutes.

> Notice. During developer preview, you will need to explicitly update the URL of shared assets in the pages and in the customizations to match CDN URL addresses. We are however working on doing this automatically with updated version, which is planned to be available later this calendar year before full worldwide release.

Video on using Office 365 Public CDN

Following videos shows in practice the steps to get started with the Office 365 Public CDN.

You can also access the video from SharePoint Patterns and Practices video channel at http://aka.ms/SPPnP-Videos.

Using Office 365 Public CDN in SharePoint Online

Here are the steps to get started with the Office 365 Public CDN.


$creds = Get-Credential
Connect-SPOService -Url https://contoso-admin.sharepoint.com/ -Credential $creds

  • Get status of the CDN settings from tenant level

Get-SPOTenant

PublicCdnEnabled : False
PublicCdnAllowedFileTypes : CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF
PublicCdnOrigins : {}

  • Enable Public CDN in the tenant

Set-SPOTenant -PublicCdnEnabled $true

  • Configure allowed file extensions (optional)
    • The default list is pre-populated. An admin can override it if they want to modify the file types which are shared

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

  • Add CDN origin
    • Note that the origin URL must point to a document library or to a folder within. Any assets under the enabled location, including sub-folders, will be accessible anonymously via CDN.

New-SPOPublicCdnOrigin -Url "https://contoso.sharepoint.com/siteassets/folder1"

  • See the list of CDN origins

Get-SPOPublicCdnOrigins

Id Url
-- ---
1937006161eeae8fe… HTTPS://CONTOSO.SHAREPOINT.COM/SITEASSETS/FOLDER1
  • Remove CDN origin
    • You can use Remove-SPOPublicCdnOrigin cmdlet for removing CDN locations based on the location identity

Remove-SPOPublicCdnOrigin -Identity 1937006161eeae8fe7159…

> Notice. It can take up to 15 minutes for the configuration changes to get reflected. 

Usage in SharePoint pages and customizations

During developer preview of this capability, you’ll need to explicitly update the used asset links and replace them with CDN URLs.  The CDN URL can be easily constructed for all the assets in the enabled library of folder, you will need to use the REST API for getting prefix for one of the assets in library/folder and use that as the constant for other assets.

The structure of CDN URL is following.


https://publiccdn.sharepointonline.com/<tenant host name>/<ID of the public CDN origin>/<sub-path under the origin> 

  • REST API to get public CDN URL for the static asset
    • The original URL will be returned if asset does not belong in any of the CDN enabled libraries, or file type is not enabled to be exposed via CDN.
    • Notice. You can’t use a browser tab to test the URL returned by this API, due to the referer limitations in the CDN. You can set this URL to an asset hosted in SharePoint to validate the URL and that everything works properly

https://contoso.sharepoint.com/ _vti_bin/publiccdn.ashx/url?itemurl=https://contoso.sharepoint.com/siteassets/folder1/folder2/image.jpg
> Output: https://publiccdn.sharepointonline.com/contoso.sharepoint.com/1937006161eeae8fe.../folder2/image.jpg

  • Image rendition support for images from the CDN can be enabled with height and widht 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
 
https://publiccdn.sharepointonline.com/contoso.sharepoint.com/1937006161eeae8fe.../image.png?height=100&width=100&cropMode=fit

Frequently asked questions

Is there a cost associated on the CDN usage?

No. This CDN capability is included as a standard service as part of your Office 365 subscription at least during the developer preview with no additional costs involved. We are evaluating the future options based on usage models.

Can I use this CDN from outside of SharePoint Online?

No. There is referrer limitation on the CDN URL requests. You can only reference assets from the CDN URLs when request is coming from the SharePoint Online.

How to validate CDN URL in Fiddler?

You can perform CDN URL validation in Fiddler if you include correct referrer header for your request.


Add header “Referer: https://contoso.sharepoint.com” to the GET request

Is the content published to CDN secured?

Content published through the Public CDN is available to everyone anonymously. We are considering providing additional options for secure content with following releases.

Once the assets are published to the library, how soon can they be accessed via CDN?

New assets added to the library can be retrieved using CDN URL immediately. However, if the assets are updated, it can take up to 15 minutes for the new version to be available via CDN URLs.

If I update my assets in the SharePoint site, will they automatically be refreshed in CDN?

Yes. You changes will be automatically reflected with the CDN URLs.

Can I manually construct the URL for the static assets?

The prefix is shared for all the items in the library / folder, so you can easily reuse the prefix cross all assets stored in same library / folder after getting the initial URL using the REST API to get public CDN URL for the first static asset.


https://publiccdn.sharepointonline.com/<tenant host name>/<ID of the public CDN origin>/<sub-path under the origin>

Questions or feedback

Please do provide us feedback on the developer preview in the SharePoint Developer space under Microsoft Tech Community. You can use this same forum also for any question around the provided capability.

“Sharing is caring”


Vesa Juvonen, Senior Program Manager, SharePoint, Microsoft – 22nd of September 2016

Feedback usabilla icon