Teams Automation - cloning Teams, SharePoint site.

Copper Contributor

Hi,

 

Our company is attempting to automate teams requests. We support 5 different teams types requests from business users. Based on teams type requested, we do specific customizations to Teams and its SharePoint site. We have 5 such teams for reference which we call teams templates.

 

Now, to automate teams creation when user submits a request, I am using a Flow that calls Office graph clone API (https://docs.microsoft.com/en-us/graph/api/team-clone?view=graph-rest-1.0) to clone the Teams template specified in user request. This clone call (https://graph.microsoft.com/beta/teams/{team-id}/clone) doesn't clone the Teams SharePoint site customizations (folders, features, permissions, etc.). It creates uncustomized SharePoint site for newly created Teams. It also creates o365 group for newly created Teams. 

 

To clone the customizations for the uncustomized Teams SharePoint site, I followed the following process:

1) Delete the uncustomized Teams SharePoint site. It also deletes the related o365 group.

2) Recover the deleted o365 group from Deleted groups in Admin Portal.

3) Go to Teams Template SharePoint site> Site Settings> 'Save site as Template' (include content). It creates a wsp. Download it.

    Note: Our teams template sharepoint sites don't have Publishing features enabled. Also our tenant allows users to run custom script on personal sites and on self-service created sites. These two pre-conditions allow us to have 'Save site as Template' option.

4) Create a new SharePoint site with same name as deleted site in SharePoint Admin Center> Active Sites> Create> Other Options (Templates)> More templates> Custom> Select Template later. Fill form and click OK. 

   Note: Instead of UI option, we can also 'Save site as Template' using following option:

        SharePoint PnP:

        Get-PnPProvisioningTemplate -Out C:\temp\template.pnp
        New-PnPTenantSite -Url 'https://tenant.sharepoint.com/sites/pnptempate' -Title 'New Site Collection' -Owner 'admin@domain.co.uk'
        Connect-PnPOnline 'https://tenant.sharepoint.com/sites/pnptempate'
        Apply-PnPProvisioningTemplate -Path C:\temp\template.pnp

5) It creates a site. You can see it under classic SharePoint site collections list as well as in Active sites list.

6) Upload the wsp to Solution Gallery of newly created SharePoint site. Activate solution.

7) Go to the site collection page, chose the wsp template under Custom tab to apply template to site. it brings in all customizations.

8) Run following commands to validate that the Teams and its o365 group are correctly bound to new SharePoint site. 

Set-SPOSiteOffice365Group -Site https://{tenantname}.sharepoint.com/sites/TeamEDF1 -DisplayName "TeamEDF1" -Alias "TeamEDF1"

# Reference: https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Set-SPOSiteOffice365Group?view=...

The commands returns output stating the site is already connected to the group. I believe it is because the site name and group name (also team name) is same.

9) Further, run following powershell to see what teams template the original teams template sharepoint site used and what template the cloned sharepoint site used:

Get-SPOSite -Limit All | select url, Template | Sort-Object Template, Url 

# Reference: https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/get-sposite?view=sharepoint-ps

Both sites show same template 'GROUP#0'

10) Furthermore, the files uploaded in Teams app for this team gets uploaded in cloned SharePoint site.

 

Our team tested the teams and found it working well but pointed to below old article from 2017 where Vesa Juvonen (Senior Program Manager, SharePoint Engineering, Microsoft) mentioned not to use 'Save site as Template'. 

https://techcommunity.microsoft.com/t5/sharepoint/save-modern-team-site-as-a-template-amp-provision-...

 

They wanted me to cross-check with Teams community.

 

Questions:

1) Can anyone please let me know if above recommendation of not to use UI option still stand correct in 2020 now that 3 years have passed since it is posted?

2) Is the SharePoint PnP Provisioning option (https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/pnp-provisioning-framework) ok to clone Teams sharepoint site?

3) Is my whole approach to automating teams creation (cloning teams + cloning teams sharepoint site) correct approach? 

 

Thanks a lot in advance,

 

Sincerely,

Ravi

1 Reply

how can prevent member to download the document in teams@ravi-edf