If you’re looking to set up the Office 365 Public CDN in SharePoint Online, you can use the following PowerShell scripts. I installed the June 2017 Release of the SharePointPnP.PowerShell Commands for this post.
After you run the script, your changes will take affect within 15 minutes. The files stored in the CDN can only be accessed within the context of SharePoint so if you try to browse to the CDN url for your asset, it will not work; however, if you reference the same url in SharePoint, it will work.
The CDN url will look like: https://publiccdn.sharepointonline.com/.sharepoint.com//
$spo = Read-Host 'Enter your SPO Service URL. (example https://<tenant>-admin.sharepoint.com)' $origin = Read-Host 'Enter the url to the CDN. (example https://<tenant>.sharepoint.com/sites/Media/CDNLibrary)' connect-sposervice $spo $tenant = Get-SPOTenant Set-SPOTenant -PublicCdnEnabled $true $tenant = Get-SPOTenant Write-host 'Public Cnd Enabled = ' $tenant.PublicCdnEnabled Write-host 'Allowed File Types = ' $t.PublicCdnAllowedFileTypes New-SPOPublicCdnOrigin -url $origin
If you need to get the Origin ID, you can find it with the following script.
$tenant = Get-SPOTenant $tenant.PublicCdnOrigins