SOLVED

How do we deploy SPFx Web Parts to a Private CDN on O365?

Iron Contributor

@Vesa Juvonen,

 

There's plenty of documentation showing how the Public CDN works with SPFx web parts, but very little (or no) discussion of how the Private CDN would work for hosting the web part javascript files.

 

I verified that the Private CDN works with my static assets (for example, .jpg files; see the "Getting the Office 365 Private CDN to work" thread), but using it for the web part files is apparently not so straight-forward. I followed the same instructions that are published for the Public CDN, but substituted the private URL in the cdnBasePath property in the Write-Manifests.json file like so:

 

Modified cdnBasePathModified cdnBasePath

All the other steps worked as expected. Everything went smoothly until I actually tried to run the thing. Placing an instance of the web part on a publishing page, the end result was this:

 

Run-time error from Web Part on the pageRun-time error from Web Part on the page

The web part is positively *singing* when I run it in the workbench (both local and in my dev site). Actually on a page, not so much.

 

What do we need to do *differently* when deploying SPFx Web Parts to a Private CDN?

 

Thanks.

5 Replies

Tried a different approach, setting the cdnbasepath to a relative URL that points to the private origin folder.  The web part now shows up and operates as expected, but inspection with an F12 in the browser shows that the web part is coming directly from the SPO document library and not from the CDN.

 

Is it possible to have a definitive answer about whether this will work or not?  Can we host SPFx web part files in a PRIVATE CDN?  Is it something that is coming? Or is it never intended to work this way, with the expectation that all SPFx web parts will use a PUBLIC CDN?

 

The direction of my development on this current project depends on the answer.  Help me Vesa-wan Kenobi, you're my only hope!

I'm also interested in an answer to that, @Waldek Mastykarz @Vesa Juvonen

best response confirmed by Joseph Ackerman (Iron Contributor)
Solution

You cannot deploy SPFx solutions using private CDN at least currently. This is due the fact that the private CDN URL is changing and is not static, which is needed, so that you can define web part host URL in the web part manifest.

 

Few pointers

 

  • Client-side web part JS files only contain JS script - not secrets or actual information, so there should not be any concerns from that perspective around hosting them from public CDN
  • If you still would like to get them hosted from fully secured URL, you'd use simply directly for example library in SharePoint without any CDN capabilities and you'd update the manifest URLs to point to that one

 

Hopefully that clarifies the situation. 

That is excellent information, thank you so much.

 

>>Client-side web part JS files only contain JS script - not secrets or actual information, so there should not be any concerns from that perspective around hosting them from public CDN<<

 

I will try to convince my client of this ;)

 

>>If you still would like to get them hosted from fully secured URL, you'd use simply directly for example library in SharePoint without any CDN capabilities <<

 

Yes thanks! I actually got this working yesterday.  I set the cdnbasepath value to a server-relative path of the library where the bundled JS and JSON files are and it worked perfectly.  My only concern was whether the performance would be adequate, but so far it looks good.

 

>>Hopefully that clarifies the situation.<<

 

It does indeed.  Thanks again!

Hi @Vesa,
I this still a limitation or latest version of the SPFx Framework have the feature to support private CDN?

Pleaes let me know.
Thanks!
1 best response

Accepted Solutions
best response confirmed by Joseph Ackerman (Iron Contributor)
Solution

You cannot deploy SPFx solutions using private CDN at least currently. This is due the fact that the private CDN URL is changing and is not static, which is needed, so that you can define web part host URL in the web part manifest.

 

Few pointers

 

  • Client-side web part JS files only contain JS script - not secrets or actual information, so there should not be any concerns from that perspective around hosting them from public CDN
  • If you still would like to get them hosted from fully secured URL, you'd use simply directly for example library in SharePoint without any CDN capabilities and you'd update the manifest URLs to point to that one

 

Hopefully that clarifies the situation. 

View solution in original post