CDN

Enable CDN

Enabling the Content Delivery Network (CDN) in SharePoint Framework (SPFx) can significantly improve the performance of your SharePoint Online pages by caching static assets closer to the users. Here’s a step-by-step guide to enable the Microsoft 365 CDN for your SPFx solutions:

  1. Connect to SharePoint Online:
    • Open the SharePoint Online Management Shell and connect to your SharePoint Online tenant using the following command: Connect-SPOService -Url https://your-tenant-admin.sharepoint.com
  2. Enable the Public CDN:
    • Run the following command to enable the public CDN: Set-SPOTenantCdnEnabled -CdnType Public
  3. Add Origins to the CDN:
    • Specify the origins (libraries) that should be included in the CDN. For example:Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl */sites/CDNLibrary
  4. Verify CDN Settings:
    • Check the status of your CDN settings with these commands:
      • Get-SPOTenantCdnEnabled -CdnType Public
      • Get-SPOTenantCdnOrigins -CdnType Public
      • Get-SPOTenantCdnPolicies -CdnType Public

Disable CDN

To disable the Content Delivery Network (CDN) for your SharePoint Framework (SPFx) solutions, you can use the following steps:

  1. Connect to SharePoint Online:
    • Open the SharePoint Online Management Shell and connect to your SharePoint Online tenant: Connect-SPOService -Url https://your-tenant-admin.sharepoint.com
  2. Disable the Public CDN:
    • Run the following command to disable the public CDN: Set-SPOTenantCdnEnabled -CdnType Public -Enable $false
  3. Remove CDN Origins:
    • If you have specific origins set up for the CDN, you can remove them using: Remove-SPOTenantCdnOrigin -CdnType Public -OriginUrl */sites/CDNLibrary
  4. Verify CDN Settings:
    • Check the status of your CDN settings to ensure they are disabled:
      • Get-SPOTenantCdnEnabled -CdnType Public
      • Get-SPOTenantCdnOrigins -CdnType Public

Configuring SPO Tenant

In this post you are going to create a new tenant for use throughout all the examples that are mentioned in SPO-Admin – development categories. We are going to install the
necessary PowerShell tools for connecting to SharePoint Online and Azure Active Directory. Finally, you will create some users that will be used for testing during the course and install the Office client.

Prepare SharePoint management PowerShell:

  • Run Windows management Shell as admin
  • Type install-module MSOnline and press enter
  • Run the following commands in order:
          a. $Credential = get-credential – Enter your. steve@CkXXXX.onmicrosoft.com user name and password,
    click OK
         b. Import-Module MSOnline
          c. Connect-MsolService –Credential $Credentia
  • Get-MsolUse –> you should receive the user data such as principal name, display name & if the user is licensed or no

Connect to your tenant

Open notepad or any text editor and add the following commands:

  • Import-Module Microsoft.Online.SharePoint.PowerShell
  • Connect-SPOService -Url https://tenant-admin.domain/ -credential UserName
  • save the file with extension ps1
  • run the file from SharePoint online management shell.

Then you will receive a popup to enter the password

You can open SharePoint online Management shell and execute directly the connect command