SharePoint Online CDN

The below content is presented so you can quicly understand Office365 CDN and execute the related commands and start enjoying the benefits of the CDN feature in your SharePoint Online environment.

Problem

There are a couple of problems if third party libraries such as moment.js, datatable.js, lodash.js, ag-grid.js and many more are used. These libraries are maintained in each site collection because there are different sets of users and permissions granted only to respective departments. With permission restriction, it is not possible to share the files across site collections.

Approaches
  1. Separate site collection can be provisioned and common libraries can be accesed and maintained. 
  2. Buy an Azure CDN storage and maintain common assets - extra cost to maintain.
  3. In-built SharePoint Online CDN which was proposed by Microsoft and current available in SharePoint Online environment.
Since SharePoint Online CDN (Office365 CDN) is currently avaible, I have complied the list of features and PowerShell commands to start enjoying :)
 
Feature Public Private
Default folders */MASTERPAGE */STYLE LIBRARY */USERPHOTO.aspx */SITEASSETS
Deleted files are accessible up to 30 days 1 hour
Can CDN be consumed from outside SharePoint? No No
Default File Types .css, .eot, .gif, .ico, .jpeg, .jpg, .js, .map, .png, .svg, .ttf, and .woff .gif, .ico, .jpeg, .jpg, .js, and .png
Files render from https://privatecdn.sharepointonline.com /<<tenantname.sharepoint.com>> /sites/<<sitename>> /<<libraryname>>/<<item>> https://public.sharepointonline.com /<<tenantname.sharepoint.com>> /sites/<<sitename>> /<<libraryname>>/<<item>>?xxxxxx
Once files are published to library, how soon can assets be accessed ? 15 Min 15 Min
Is there any cost to use Office365 CDN? No No
 
To run the below list of commands, you need to install  SharePoint Online Management Shell and run the following commands.
 
Connect SharePoint Online from PowerShell Window
  1. $adminUPN="<the full email address of a SharePoint Online global administrator account, example: [email protected]>"  
  2. $orgName="<name of your Office 365 organization, example: srinivasnarula>"  
  3. $userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."  
  4. Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential  
Get status of private CDN
  1. Get-SPOTenantCdnEnabled -CdnType private
Enable private CDN in tenant
  1. Set-SPOTenantCdnEnabled -CdnType private
Add new private CDN Origin
  1. Add-SPOTenantCdnOrigin -CdnType private -OriginUrl sites/<<SiteName>>/<<LibraryName>>  
Remove private CDN Origins
  1. Remove-SPOTenantCdnOrigin -CdnType private -OriginUrl sites/<<SiteName>>/<<LibraryName>>  
List all private CDN Origins
  1. Get-SPOTenantCdnOrigins -CdnType private
Disable private DN Origin
  1. Set-SPOTenantCdnEnabled -CdnType private -Enable $false  
To use the public CDN, replace private with public keywords in the above commands.
Ebook Download
View all
Learn
View all