Nov 23 2018 02:42 AM
I am planning to create a Modern Team Site using Template pro grammatically using CSOM or PnP
could you please direct me to a link where
1) to create a template of a modern team site - techniques
2) sample code for creating the site programmatically
Nov 28 2018 02:58 AM - edited Nov 29 2018 06:33 AM
Hi there,
To grab the template of a modern team site, you can use PnP PowerShell (or C#) Get-PnPProvisioningTemplate.
How to create the modern team site programmatically will depend on whether you want it to be group connected or not. For a non group connected team site, simply call your normal CSOM or PnP method for creating a site and pass in Template STS#3.
For a group connected team site, you need to create an Office 365 group and pass in a "mailNickname" parameter which will determine the name of the team site.
You can do this in a number of ways. With REST via a POST request to the Graph endpoint: https://graph.microsoft.com/v1.0/groups
The following would create an Office 365 group and an associated "modern" team site with a URL of https://[tenant].sharepoint.com/sites/mymodernteamsite
POST https://graph.microsoft.com/v1.0/groups
Content-type: application/json
Content-length: 200
{
"description": "description",
"displayName": "My modern team site",
"groupTypes": [
"Unified"
],
"mailEnabled": true,
"mailNickname": "mymodernteamsite",
"securityEnabled": false
}
You can also achieve this via PowerShell as explained in the following article
Note that you can't create group connected team sites using PowerShell with App-Only permissions yet, however, you should be able to call the Graph endpoint.
Nov 29 2018 04:41 AM
Is there a way to use CSOM or PnP method for creating a site and pass in Template STS#3 using C#?
As i want to create the site collection programmatically using templates based on Modern Team Sites without group creation.
Thanks
Nov 29 2018 06:23 AM - edited Nov 29 2018 06:31 AM
Using the PnP Core library, you can use the tenant extension method, "CreateSiteCollection", which accepts a SiteEntity object as a parameter. That SiteEntity object defines (among other things) the template (STS#3 in this case).
I would use the PnP method. Inside that method you'll see the CSOM method it's wrapped around (tenant.CreateSite()) which takes a SiteCreationProperties object which defines the template. You could also use that method directly if you want pure CSOM.
Dec 12 2018 11:58 AM
I am getting the below error
https://github.com/SharePoint/PnP-Sites-Core/issues/1450
Is the PnP Templating mature enough to be embraced in the industry or should we go for Site Script - Site design approach.
I am not sure if Microsoft would support PnP or Site Script/Design as it appears PnP has not matured to handle Modern Team site with themes o be applied.
Could you please shed some light on this.