PnP-Provisioning-Schema
PnP-Provisioning-Schema copied to clipboard
Provisioning Teams site and Teams
Hi there,
I just started with the PnP Provisioning schema. For a customer I need to built a template which contains a site collection and a team (which is obviously connected to this site).
It's necessary to run it without a logged in user as we gonna move it to Azure DevOps. So I created an app registration with a certificate and Api permissions:
- Microsoft Graph: Directory.ReadWriteAll, Group.Create, Group.ReadWrite.All, GroupMember.ReadWriteAll, Sites.FullControll.All, Sites.Manage.All, Sites.ReadWrite.All, Teams.Create, TeamMember.ReadWrite.All, User.Read
- SharePoint: Sites.FullControl.All Sites.Manage.All Sites.ReadWriteAll.
The site is created but it stops with an exception. The site is however created with wrong settings (language incorrect, no additional owners, etc.) The error (Get-PnPException):
Object reference not set to an instance of an object. Stacktrace : at PnP.Framework.Graph.UnifiedGroupsUtility.<UpdateMembers>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PnP.Framework.Graph.UnifiedGroupsUtility.<>c__DisplayClass19_0.<<AddUnifiedGroupMembers>b__0>d .MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PnP.Framework.Graph.UnifiedGroupsUtility.AddUnifiedGroupMembers(String groupId, String[] membe rs, String accessToken, Boolean removeExistingMembers, Int32 retryCount, Int32 delay, AzureEnvironme nt azureEnvironment) at PnP.Framework.Sites.SiteCollection.<CreateTeamSiteViaGraphAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PnP.Framework.Sites.SiteCollection.<CreateAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at PnP.Framework.Provisioning.ObjectHandlers.ObjectHierarchySequenceSites.ProvisionObjects(Tenant tenant, ProvisioningHierarchy hierarchy, String sequenceId, TokenParser tokenParser, ApplyConfigura tion configuration) at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyTenantTemplate(Tenant tenant, ProvisioningHierarchy hierarchy, String sequenceId, ApplyConfiguration configuration) at PnP.PowerShell.Commands.Provisioning.Tenant.InvokeTenantTemplate.ExecuteCmdlet() at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord()
I already did come investigation. Here are some findings:
- When I execute the same with Connect-PnPOnline -Interactive it works. This is obviously as i'm using a global admin
- When I first create the site with New-PnPSite and then invoke the template it also works.
- When It fails the first time, I add the owner at group-level, invoke it again, it works.
I personally think is had something to do with the Graph Api, but I cannot find anything.
The template (I removed the parameters and header of the file as its not relevant)
` <pnp:Templates ID="CONTAINER-TEMPLATES"> <pnp:ProvisioningTemplate ID="TEMPLATE-GENERAL" Version="1.0" BaseSiteTemplate="GROUP#0" DisplayName="Special Team Site" Description="This is a Special Team Site for custom provisioning" Scope="RootSite" TemplateCultureInfo="1043">
<pnp:WebSettings RequestAccessEmail=""
QuickLaunchEnabled="true"
MembersCanShare="true"
SiteLogo=""
AlternateCSS=""
MasterPageUrl="{site}/_layouts/15/online/spo.master"
CustomMasterPageUrl="{masterpagecatalog}/spo.master"
SearchScope="DefaultScope"
SearchBoxInNavBar="Inherit" />
<pnp:SiteSettings AllowDesigner="true"
AllowCreateDeclarativeWorkflow="true"
AllowSaveDeclarativeWorkflowAsTemplate="true"
AllowSavePublishDeclarativeWorkflow="true"
SearchBoxInNavBar="Inherit"
SearchCenterUrl="" />
<pnp:RegionalSettings AdjustHijriDays="0"
AlternateCalendarType="None"
CalendarType="Gregorian"
Collation="25"
FirstDayOfWeek="Monday"
FirstWeekOfYear="0"
LocaleId="1043"
ShowWeeks="false"
Time24="true"
TimeZone="13"
WorkDayEndHour="5:00PM"
WorkDays="62"
WorkDayStartHour="8:00AM" />
<pnp:PropertyBagEntries>
<pnp:PropertyBagEntry Key="Department"
Value="{parameter:Department}"
Overwrite="false" />
</pnp:PropertyBagEntries>
<pnp:Security
AssociatedOwnerGroup="{groupsitetitle} Owners"
AssociatedMemberGroup="{groupsitetitle} Members"
AssociatedVisitorGroup="{groupsitetitle} Visitors">
<pnp:AdditionalAdministrators>
<pnp:User Name="i:0#.f|membership|[email protected]" />
</pnp:AdditionalAdministrators>
<pnp:AdditionalOwners>
<pnp:User Name="i:0#.f|membership|[email protected]" />
</pnp:AdditionalOwners>
<pnp:Permissions />
</pnp:Security>
</pnp:ProvisioningTemplate>
</pnp:Templates>
<pnp:Sequence ID="CREATE-SITE">
<pnp:SiteCollections>
<pnp:SiteCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="pnp:TeamSite"
ProvisioningId="TEAM.SITE.01"
Title="{parameter:Prefix}-{parameter:TeamTitle}"
Alias="{parameter:Prefix}-{parameter:TeamAlias}"
DisplayName="{parameter:Prefix}-{parameter:TeamAlias}"
IsPublic="false"
IsHubSite="false"
Description="{parameter:Prefix}-{parameter:TeamAlias}"
Language="1043">
<pnp:Templates>
<pnp:ProvisioningTemplateReference ID="TEMPLATE-GENERAL"/>
</pnp:Templates>
</pnp:SiteCollection>
</pnp:SiteCollections>
</pnp:Sequence>
<pnp:Teams>
<pnp:Team GroupId="{sequencesitegroupid:TEAM.SITE.01}" DisplayName="{parameter:Prefix}-{parameter:TeamAlias}" Description="{parameter:TeamTitle}" Visibility="Private" MailNickname="{parameter:Prefix}-{parameter:TeamAlias}">
<pnp:Channels>
<pnp:Channel DisplayName="General"
Description="General"
IsFavoriteByDefault="true">
<pnp:Tabs>
<pnp:Tab DisplayName="{parameter:Prefix}-{parameter:TeamAlias}" TeamsAppId="com.microsoft.teamspace.tab.files.sharepoint">
<pnp:Configuration EntityId=""
ContentUrl="{sequencesiteurl:TEAM.SITE.01}/Documenten"
WebsiteUrl=""
RemoveUrl="" />
</pnp:Tab>
</pnp:Tabs>
</pnp:Channel>
</pnp:Channels>
</pnp:Team>
</pnp:Teams>
</pnp:Provisioning> `
Have the same issue. If a run the command a second time, the provisioning start correclty.