Apply-PnPProvisiongTemplate on Modern Site Referenced content type not available in site or in templ

Copper Contributor

I need to provision a modern UI site and apply a pnp template to create document libraries, security groups, home page etc in one go.

 

I have a XML PnP Template which creates a list referencing a custom content type from the content type hub.

 

I create a Classic Sites with New-SPOSite (In PowerShell) with parameter -Template "STS#3". Then apply the PnP template with Apply-PnPProvisioningTemplate. This is successful and the document library is created with the content type.

 

However, if I create a modern site with New-SPOSite with parameter -Template "STS#3". Then apply the same PnP template I get the following error. “Referenced content type 0x0101007BD61AFCC8A643B8924AB3F7EE18260105 not available in site or in template”

 

It seems that the PnP Provisioning engine will happily ‘connect’ with Content Types in the Hub for Classic sites but not Modern Sites.

 

Is this a bug with PnP Provisioning engine or a feature of Modern Sites or I have a missing a Pnp Template configuration? Is there work around other than to wait for the Modern site to eventually have the Content Types Syndicated?

 

I have tried provisioning the custom content type locally with the same id and reference in the document library. Later content type becomes syndicated from the hub. However, the custom content site uses a taxonomy field which requires a note field with name of the taxonomy field’s guid. The syndication errors saying the note field already exists.

 

Trace log

Stack Trace is [OfficeDevPnP.Core] [0]    [Information] File ClientSiteListCTIssue.xml retrieved from folder  0ms    

[OfficeDevPnP.Core] [0] [Information] File ClientSiteListCTIssue.xml retrieved from folder  0ms    

[Provisioning] [13] [Debug] Code execution scope started 0ms 21292f6d-190b-4146-99c1-ec5a2139425d

[Provisioning] [13] [Information] ProgressDelegate registered 0ms 21292f6d-190b-4146-99c1-ec5a2139425d

[Provisioning] [13] [Information] MessagesDelegate registered 0ms 21292f6d-190b-4146-99c1-ec5a2139425d

[Extensibility Providers] [13] [Debug]      Code execution scope started 0ms 21292f6d-190b-4146-99c1-ec5a2139425d

[Extensibility Providers] [13] [Debug]      Code execution scope ended 0ms 21292f6d-190b-4146-99c1-ec5a2139425d

[List instances] [13] [Debug] Code execution scope started 0ms 21292f6d-190b-4146-99c1-ec5a2139425d

[List instances] [13] [Error] Referenced content type 0x0101007BD61AFCC8A643B8924AB3F7EE18260105 not available in site or in template 1882ms 21292f6d-190b-4146-99c1-ec5a2139425d

[List instances] [13] [Debug] Code execution scope ended 1882ms 21292f6d-190b-4146-99c1-ec5a2139425d

[Provisioning] [13] [Debug] Code execution scope ended 15183ms 21292f6d-190b-4146-99c1-ec5a2139425d

 

Minimum Pnp Template definition to replicate problem

<?xml version="1.0"?>

<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2018/05/ProvisioningSchema">

    <pnp:Preferences Author="Content and Code" Version="1.0" Generator="OfficeDevPnP.Core, Version=2.18.1709.0, Culture=neutral, PublicKeyToken=3751622786b357c2"/>

 

  <pnp:Templates ID="MM-TEMPLATES">

    <pnp:ProvisioningTemplate ID="MM-CLIENTSITE" Version="1"

      BaseSiteTemplate="STS#3"

      DisplayName="My site"

      Description="A template for a my  site"

      Scope="RootSite">

 

      <pnp:WebSettings

        NoCrawl="false"

        Title="Title"

        Description="Site Description"

        MasterPageUrl="{masterpagecatalog}/seattle.master"

        WelcomePage="SitePages/Home.aspx"

        CustomMasterPageUrl="{masterpagecatalog}/seattle.master" />

 

      <pnp:Lists>

        <pnp:ListInstance Title="CT Hub Test" Url="cthubtest" OnQuickLaunch="true" TemplateType="101" ContentTypesEnabled="true" EnableVersioning="true" EnableMinorVersions="true" >

          <pnp:ContentTypeBindings>

            <pnp:ContentTypeBinding ContentTypeID="0x0101007BD61AFCC8A643B8924AB3F7EE18260105" Default="true"/>

          </pnp:ContentTypeBindings>

        </pnp:ListInstance>                              

      </pnp:Lists>

    </pnp:ProvisioningTemplate>

  </pnp:Templates>

</pnp:Provisioning>

1 Reply

I guess what you're already suggesting is indeed the case. Content Type syndication from the hub seems to be processed asynchronously for modern sites instead of synchronously for classic sites. This is one of the reasons provisioning of modern team sites  is so much faster than provisioning of classic sites.

 

I don't consider this a bug in the PnP Provisioning engine. My suggestion is to extract your Content TYpe and Field definitions (schema XML) from the hub and include it in your Provisioning Template XML so that you have the Content Type available while provisioning and you're able to associate it with your library. Eventually the Content Type will be syndicated from the hub with updates made (if any) after you extracted your definitions.

 

Hope this helps!