The Office 365 Public CDN Developer Preview was recently announced which allows static assets like images, JavaScript, CSS etc. to be hosted in a globally available CDN. Find out more about it here.
With the Office 365 Public CDN Developer Preview, the Office 365 PowerShell and SharePoint Online CSOM was also updated with APIs which could be used to manage the Public CDN.
Although the APIs were handy, what was missing was a nice and simple GUI to manage the CDN settings. So I set out to create an Add-In which would give a nice overview of all the CDN settings including folders in the tenant which have been configured as Origins, filetypes which have been set to be pushed to the CDN and finally a way to enable/disable the CDN.
Although the APIs were handy, what was missing was a nice and simple GUI to manage the CDN settings. So I set out to create an Add-In which would give a nice overview of all the CDN settings including folders in the tenant which have been configured as Origins, filetypes which have been set to be pushed to the CDN and finally a way to enable/disable the CDN.
Introducing the SharePoint Online Public CDN Manager:
Checkout the code on GitHub: https://github.com/vman/SPO-CDN-Manager
As you can tell, the SharePoint Online Public CDN Manager can be used to:
1) Add/Remove CDN Origins i.e. SPO Libraries which will be used to store static assets.
2) Add/Remove Filetypes. Which files will be pushed to the CDN.
3) Enable/Disable the CDN on a tenant.
The Implementation:
https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-october-2016
2) For the UI, the Office UI Fabric core styles are used together with the Office UI Fabric JS Components
3) The Add-In requires Full Control permissions on the tenant. This is because the CDN is a tenant wide setting and can be modified only by Tenant Administrators or SharePoint Administrators.
The Add-In uses User + App authentication for every call to SharePoint so that only Tenant/SharePoint Administrators can access the CDN Properties:
So even if a user who is not an Admin lands on the page, they are not able to fiddle with the CDN settings.
The Add-In uses User + App authentication for every call to SharePoint so that only Tenant/SharePoint Administrators can access the CDN Properties:
So even if a user who is not an Admin lands on the page, they are not able to fiddle with the CDN settings.
Tenant vs Office365Tenant
Microsoft.Online.SharePoint.TenantManagement.Office365Tenant
Microsoft.Online.SharePoint.TenantAdministration.Tenant
Both these classes have the Public CDN properties which can be used to manage the CDN. But the interesting this is that the Tenant class requires the Tenant Administration Url (https://yourtenant-admin.sharepoint.com) to instantiate but the Office365Tenant class can be instantiated by a regular site url in SharePoint Online. (https://yourtenant.sharepoint.com/sites/publishing)
If a regular SharePoint site url is used to instantiate the Tenant class, you get an exception saying:
Current site is not a tenant administration site.
This is why I have used the Office365Tenant class. Checkout the code on GitHub for more details.
Workaround for Internet Explorer "Quirks":
But, to get it working on IE, you will have to add the remote site where you provider hosted Add-In is deployed to IE's trusted sites. In my case, I have deployed the Add-In to an Azure Web App so I had to add https://spocdnmanager.azurewebsites.net to IE's trusted sites.
Thanks for reading! Hope you find the SPO CDN Manager useful.