Provision sub site using PnP Site provisioning schema?

%3CLINGO-SUB%20id%3D%22lingo-sub-16289%22%20slang%3D%22en-US%22%3EProvision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16289%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20provision%20a%20site%20hierarchy%20using%20the%20PnP%20site%20provisioning%20engine%20and%20an%20.xml%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20thing%20I%20am%20having%20a%20bit%20of%20a%20problem%20with%20is%20how%20do%20I%20provision%20sub%20sites%3F%20I%20want%20to%20provision%20the%20following%20example%20of%20a%20site%20structure%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EStart%20page%3C%2FLI%3E%3CLI%3EAbout%20us%20(subsite%2C%20team%20site)%3C%2FLI%3E%3CLI%3EResources%20(subsite%2C%20team%20site)%3C%2FLI%3E%3CLI%3ECommunity%20(Community%20site%20%E2%80%93%20site%20collection)%3C%2FLI%3E%3CLI%3EDocuments%20(Document%20center%20%E2%80%93%20Site%20collection)%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2F%2FMartin%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-132042%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-132042%22%20slang%3D%22en-US%22%3EThat%20would%20not%20deploy%20the%20content%20types%20to%20a%20subsite%20if%20the%20contentypes%20in%20the%20template%20are%20site%20collection%20content%20types.%20I%20would%20expect%20that%20contenttypes%20that%20are%20exported%20at%20a%20certain%20scope%20(%20site%20collection%2C%20web%2C%20list)%20to%20keep%20their%20scope.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-131964%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131964%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2387%22%20target%3D%22_blank%22%3E%40Pieter%20Veenstra%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20a%20flag%20to%20allow%20for%20ContentTypes%20to%20be%20provisioned%20to%20sub%20webs%20(-ProvisionContentTypesToSubWebs).%20Is%20that%20feature%20depreciated%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37425%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37425%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35150%22%20target%3D%22_blank%22%3E%40nitinkumar%20kakulde%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20is%20expected%20behaviour.To%20get%20the%20content%20types%20and%20fields%20you%20will%20bneed%20to%20export%20the%20root%20site%20within%20your%20site%20collection%20and%20then%20apply%20that%20to%20the%20rootsite%20of%20the%20site%20collection%20where%20you%20want%20these%20contenttypes%20to%20appear.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37375%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37375%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20tried%20all%20the%20way%20for%20migrating%20sub%20site%20CT%20from%20one%20tenant%20to%20another%20tenant.%20CT%20which%20are%20created%20at%20subsite%20levels%20and%20columns%20which%20are%20taken%20in%20the%20CT%20which%20are%20from%20the%20site%20collection%20levels%20not%20getting%20exported%20even.%20Import%20is%20failed%20too.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20migrated%20SC%20level%20all%20CT%20and%20site%20structure%20and%20then%20migrated%20sub%20site%20level%20structure%20where%20CT%2C%20Site%20columns%20are%20missing%20from%20the%20exported%20xml%20file.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37268%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37268%22%20slang%3D%22en-US%22%3E%3CP%3ENot%20deploy%20or%20not%20working%20subsite%20to%20subsite%20migration%20of%20the%20Site%20structure.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37267%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37267%22%20slang%3D%22en-US%22%3E%3CP%3EI%20did%20all%20try%20using%20the%20sub%20site%20structure%20migration%20using%20your%20mentioned%20commands%20for%20our%20project.%20Its%20only%20migrate%20the%20Site%20collection%20level%20structure%20not%20sub%20site%20level%20structure.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20observe%20is%20subsite%20level%20structure%20migration%20shows%20things%20to%20be%20done%20in%20PowerShell%20log%20trace%20but%20actually%20nothing%20get%20created%20in%20the%20targeted%20subsite.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16611%22%20slang%3D%22en-US%22%3ERE%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16611%22%20slang%3D%22en-US%22%3EPnP%20engine%20does%20not%20provision%20any%20sites.%20It%20is%20only%20able%20to%20apply%20templates%20on%20an%20existing%20site%20or%20extract%20a%20template%20from%20an%20existing%20site.%20So%20from%20your%20code%20or%20powershell%2C%20first%20provision%20a%20new%20sub%20site%20and%20then%20apply%20a%20template%20on%20it.%20This%20can%20be%20done%20using%20pnp.core%20extensions%20or%20using%20plain%20csom%2Frest%20api's.%20Within%20the%20PnP%20schema%20there%20is%20a%20sequence%20element%20available%20in%20order%20to%20define%20a%20site%20structure%20(site%20collections%20and%20sites).%20Only%20the%20PnP%20engine%20does%20not%20do%20anything%20(yet)%20with%20the%20sequences.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16317%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16317%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F18790%22%20target%3D%22_blank%22%3E%40Martin%20Segelfeldt%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethat%20would%20be%20a%20nice%20idea%20but%20that's%20not%20how%20the%20PnP%20Provisioing%20engine%20works.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20an%20addtional%20xml%20structure%20that%20lists%20out%20all%20the%20sites%20I%20want%20to%20deploy.%20Then%20a%20powerShewll%20script%20reads%20this%20xml%20and%20provisions%20all%20the%20sites%20by%20calling%20the%20Apply-SPOProvisioningTemplate%20multiple%20times.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16314%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16314%22%20slang%3D%22en-US%22%3E%3CP%3EThen%20i%20need%20to%20call%26nbsp%3B%3CSPAN%3EApply-SPOProvisioninTemplate%20multiple%20times%20and%20split%20this%20up%20in%20multiple%20xml%20files.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExample%3C%2FP%3E%3CP%3E%3CSPAN%3EApply-SPOProvisioninTemplate%20-web%20subweburl1%20-Path%20c%3A%5Ctemp%5Ctemplate1.xml%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EApply-SPOProvisioninTemplate%20-web%20subweburl2%20-Path%20c%3A%5Ctemp%5Ctemplate2.xml%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EApply-SPOProvisioninTemplate%20-web%20subweburl3%20-Path%20c%3A%5Ctemp%5Ctemplate3.xml%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EApply-SPOProvisioninTemplate%20-web%20subweburl4%20-Path%20c%3A%5Ctemp%5Ctemplate4.xml%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EWhat%20i%20would%20like%20to%20do%20is%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EApply-SPOProvisioninTemplate%20-web%20rootsite%20-Path%20c%3A%5Ctemp%5Crootsite.xml%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAnd%20rootsite.xml%20contains%20something%20like%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSUBSITES%3E%3C%2FSUBSITES%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSUBSITE%20url%3D%22%26quot%3Bsubweburl1%26quot%3B%22%3E%3C%2FSUBSITE%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%20%2F%2FStuff%20here%20%3A)%3C%2Fimg%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSUBSITE%20url%3D%22%26quot%3Bsubweburl2%26quot%3B%22%3E%3C%2FSUBSITE%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%20%2F%2FStuff%20here%20%3A)%3C%2Fimg%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSUBSITE%20url%3D%22%26quot%3Bsubweburl3%26quot%3B%22%3E%3C%2FSUBSITE%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%20%2F%2FStuff%20here%20%3A)%3C%2Fimg%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSUBSITE%20url%3D%22%26quot%3Bsubweburl4%26quot%3B%22%3E%3C%2FSUBSITE%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%20%2F%2FStuff%20here%20%3A)%3C%2Fimg%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16296%22%20slang%3D%22en-US%22%3ERe%3A%20Provision%20sub%20site%20using%20PnP%20Site%20provisioning%20schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16296%22%20slang%3D%22en-US%22%3E%3CP%3Eif%20you%20are%20using%20PowerShell%20then%20after%20you%20connect%20to%20your%20site%20collection%20you%20can%20specify%20the%20web%20that%20you%20want%20to%20provision%20your%20template%20to.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EApply-SPOProvisioninTemplate%20-web%20subweburl%20-Path%20c%3A%5Ctemp%5Ctemplate.xml%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I am trying to provision a site hierarchy using the PnP site provisioning engine and an .xml file.

 

One thing I am having a bit of a problem with is how do I provision sub sites? I want to provision the following example of a site structure

 

  • Start page
  • About us (subsite, team site)
  • Resources (subsite, team site)
  • Community (Community site – site collection)
  • Documents (Document center – Site collection)

 

//Martin

10 Replies
Highlighted

if you are using PowerShell then after you connect to your site collection you can specify the web that you want to provision your template to.

 

Apply-SPOProvisioninTemplate -web subweburl -Path c:\temp\template.xml

 

 

Highlighted

Then i need to call Apply-SPOProvisioninTemplate multiple times and split this up in multiple xml files.

 

Example

Apply-SPOProvisioninTemplate -web subweburl1 -Path c:\temp\template1.xml

Apply-SPOProvisioninTemplate -web subweburl2 -Path c:\temp\template2.xml

Apply-SPOProvisioninTemplate -web subweburl3 -Path c:\temp\template3.xml

Apply-SPOProvisioninTemplate -web subweburl4 -Path c:\temp\template4.xml

 

What i would like to do is

 

Apply-SPOProvisioninTemplate -web rootsite -Path c:\temp\rootsite.xml

 

And rootsite.xml contains something like

<SubSites>

<SubSite url="subweburl1">

  //Stuff here :)

</SubSite>

<SubSite url="subweburl2">

  //Stuff here :)

</SubSite>

<SubSite url="subweburl3">

  //Stuff here :)

</SubSite>

<SubSite url="subweburl4">

  //Stuff here :)

</SubSite>

</SubSites>

Highlighted

Hi @Martin Segelfeldt,

 

that would be a nice idea but that's not how the PnP Provisioing engine works.

 

I created an addtional xml structure that lists out all the sites I want to deploy. Then a powerShewll script reads this xml and provisions all the sites by calling the Apply-SPOProvisioningTemplate multiple times.

Highlighted
PnP engine does not provision any sites. It is only able to apply templates on an existing site or extract a template from an existing site. So from your code or powershell, first provision a new sub site and then apply a template on it. This can be done using pnp.core extensions or using plain csom/rest api's. Within the PnP schema there is a sequence element available in order to define a site structure (site collections and sites). Only the PnP engine does not do anything (yet) with the sequences.
Highlighted

I did all try using the sub site structure migration using your mentioned commands for our project. Its only migrate the Site collection level structure not sub site level structure. 

 

What I observe is subsite level structure migration shows things to be done in PowerShell log trace but actually nothing get created in the targeted subsite.

 

 

Highlighted

Not deploy or not working subsite to subsite migration of the Site structure. 

Highlighted

I have tried all the way for migrating sub site CT from one tenant to another tenant. CT which are created at subsite levels and columns which are taken in the CT which are from the site collection levels not getting exported even. Import is failed too. 

 

We have migrated SC level all CT and site structure and then migrated sub site level structure where CT, Site columns are missing from the exported xml file. 

Highlighted

Hi @nitinkumar kakulde,

 

That is expected behaviour.To get the content types and fields you will bneed to export the root site within your site collection and then apply that to the rootsite of the site collection where you want these contenttypes to appear.

Highlighted

Hi @Pieter Veenstra

 

There is a flag to allow for ContentTypes to be provisioned to sub webs (-ProvisionContentTypesToSubWebs). Is that feature depreciated?

Highlighted
That would not deploy the content types to a subsite if the contentypes in the template are site collection content types. I would expect that contenttypes that are exported at a certain scope ( site collection, web, list) to keep their scope.