question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when provisioning a template with a TeamSite and MS Teams (or teamify)

See original GitHub issue

When provisioning a Template that contains a pnp:TeamSite, and a MS teams node (or just the “teamify” attribute in the TeamSite), you get an exception from MS Graph API, as the Group behind the TeamSite was created with no Owners nor Members.

As far as we’ve seen debugging, the Teams object handler is calling:

private static string CreateOrUpdateTeamFromGroupInternal(PnPMonitoredScope scope, Team team, TokenParser parser, string groupId, string accessToken)

and that method calls the Graph helper

teamId = GraphHelper.CreateOrUpdateGraphObject(scope,
                    HttpMethodVerb.PUT,
                    $"{GraphHelper.MicrosoftGraphBaseURI}v1.0/groups/{groupId}/team",
                    content,
                    HttpHelper.JsonContentType,
                    accessToken,
                    "Conflict",
                    CoreResources.Provisioning_ObjectHandlers_Teams_Team_AlreadyExists,
                    "id",
                    parser.ParseString(team.GroupId),
                    CoreResources.Provisioning_ObjectHandlers_Teams_Team_ProvisioningError,
                    canPatch: true);

and although there´s no Exception, the TeamId is returned as null, as the helper is catching the MS Graph API exception. The request to Graph API is:

PUT https://graph.microsoft.com/v1.0/groups/{group_id}/team HTTP/1.1

{"funSettings":{"allowGiphy":true,"giphyContentRating":"moderate","allowStickersAndMemes":true,"allowCustomMemes":true},"guestSettings":{"allowCreateUpdateChannels":false,"allowDeleteChannels":false},"memberSettings":{"allowCreateUpdateChannels":true,"allowAddRemoveApps":true,"allowDeleteChannels":true,"allowCreateUpdateRemoveTabs":true,"allowCreateUpdateRemoveConnectors":true,"allowCreatePrivateChannels":false},"messagingSettings":{"allowUserEditMessages":true,"allowUserDeleteMessages":true,"allowOwnerDeleteMessages":true,"allowTeamMentions":true,"allowChannelMentions":true}}

and the response says clearly that there´s no Owner for that group.

{
  "error": {
    "code": "BadRequest",
    "message": "Team owner not found for group 10107cf.........633.",
    "innerError": {
      "date": "2021-01-27T15:37:35",
      "request-id": "9f4beda6-....1deb8f",
      "client-request-id": "9f4b......deb8f"
    }
  }
}

the problem here is that we cannot specify an Owner when creating the TeamSite, as the PnP Schema doesn´t allow it.

Any thoughts here? @PaoloPia @jansenbe

Many thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gautamdshethcommented, Feb 11, 2021

@luismanez - this is a bit “complex” , requiring us to change the schema to support owners property which might take sometime .

As a temporary workaround , we can try it as below using the UnifiedGroupsUtility’s CreateUnifiedGroup method. You can specify the owner array as well and pass the same access token inside the PnPProvisioningContext. Once the group + team are created, you can then apply the PnP Template to the created team site.

var group = var group = UnifiedGroupsUtility.CreateUnifiedGroup("display name", "desc", "mailNickName", accessToken, owners[], createTeam: true);
var siteUrl = group.SiteUrl;

using(ClientContext ctx = new ClientContext(siteUrl))
{
    ctx.Web.ApplyProvisioningTemplate
}
1reaction
luismanezcommented, Jan 28, 2021

I can confirm that the template posted above is enough to get the error when using App Only auth. Code below is how we´re calling ApplyTenantTemplate:

            using (new PnPProvisioningContext((resource, scope) => tokenProvider.GetAccessToken(resource, scope)))
            {
                using var tenantContext = await sharePointContextProvider.GetTenantContext();
                var tenant = new Tenant(tenantContext);

                tenant.ApplyTenantTemplate(provisioningHierarchy, provisioningHierarchy.Sequences[0].ID, applyingInformation);
            }

The tokenProvider.GetAccessToken function is returning a valid token for MS Graph. Actually, the Group is created using Graph API, but as the framework is not adding any Owner to the group, and using AppOnly token, no Owners are added to the Group, and the next call to configure the MS Teams team (teamify group), fails with the error already mentioned below.

I think the solution here is to allow to pass an Owner from the Schema, like actually is already done with pnp:TeamSiteNoGroup

BTW, also tested to create a TeamSite with NO Group, and then tried to Groupify and Temify, but in this case it also fails in a different point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Error internal to Apply_PnPTenantTemplate - ...
Properly formatted PnP Provisioning Template with two teams ... it seems to have created the associated Group and Team Site in SharePoint.
Read more >
How to create a Microsoft teams to an existing team site?
Hi there, We have this team site and would like to connect/add an MS teams but there's no option/ button showing on our...
Read more >
Error when provisioning a site
I have a simple site as template and the extract works just fine. But when I try to Provision it to another site...
Read more >
Sharepoint Online - Provisioning Failure - Microsoft Q&A
From what i understand the provisioning tool creates new sites based on a template. Is there a way to manually create the site...
Read more >
Access denied when applying template to team site (Group ...
Hi,. I'm trying to export and import a team site (group site) from Office 365 but I have a few issues applying the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found