Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues with teams provisioning and parameters handling #1106

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static JToken CreateTeamFromProvisioningSchema(PnPMonitoredScope scope,
// If security is configured, add the members and owners defined in the template to the Team
if (team.Security != null)
{
if (!SetGroupSecurity(scope, parser, team, teamId, accessToken, graphBaseUri)) return null;
if (!SetGroupSecurity(scope, parser, team, parsedGroupId, accessToken, graphBaseUri)) return null;
}

// Then promote the Group into a Team or update it, if it already exists. Patching a team doesn't return an ID, so use the parsedGroupId directly (teamId and groupId are the same).
Expand Down Expand Up @@ -1461,7 +1461,7 @@ private static string CreateTeamChannelMessage(PnPMonitoredScope scope, TokenPar

var messageId = GraphHelper.CreateOrUpdateGraphObject(scope,
HttpMethodVerb.POST,
$"{graphBaseUri}beta/teams/{teamId}/channels/{channelId}/messages",
$"{graphBaseUri}v1.0/teams/{teamId}/channels/{channelId}/messages",
messageObject,
HttpHelper.JsonContentType,
accessToken,
Expand Down Expand Up @@ -1697,6 +1697,10 @@ public override TokenParser ProvisionObjects(Tenant tenant, ProvisioningHierarch
{
// Get a fresh Access Token for every request
accessToken = PnPProvisioningContext.Current.AcquireToken(graphBaseUri.ToString(), "Group.ReadWrite.All");
if (accessToken == null)
{
accessToken = PnPProvisioningContext.Current.AcquireToken(graphBaseUri.Host, "Group.ReadWrite.All");
}

if (accessToken != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public partial class ProvisioningTemplateApplyingInformation
public ProvisioningMessagesDelegate MessagesDelegate { get; set; }
public ProvisioningSiteProvisionedDelegate SiteProvisionedDelegate { get; set; }

public Dictionary<string, string> Parameters { get; set; }

internal ApplyConfiguration ApplyConfiguration { get; set; }
/// <summary>
/// If true then persists template information
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using PnP.Framework.Diagnostics;
using PnP.Framework.Http;
using PnP.Framework.Provisioning.Model;
Expand Down Expand Up @@ -155,6 +156,10 @@ internal void ApplyTenantTemplate(Tenant tenant, PnP.Framework.Provisioning.Mode
}
else
{
// Apply the configuration parameters to the hierarchy
ApplyConfigurationParameters(configuration.Parameters, hierarchy.Parameters);

// Configure all the delegates to monitor the provisioning process
progressDelegate = configuration.ProgressDelegate;
if (configuration.ProgressDelegate != null)
{
Expand Down Expand Up @@ -221,6 +226,24 @@ internal void ApplyTenantTemplate(Tenant tenant, PnP.Framework.Provisioning.Mode
}
}

private static void ApplyConfigurationParameters(Dictionary<string, string> sourceParameters, Dictionary<string, string> destParameters)
{
if (sourceParameters != null)
{
foreach (var p in sourceParameters)
{
if (!destParameters.ContainsKey(p.Key))
{
destParameters.Add(p.Key, p.Value);
}
else
{
destParameters[p.Key] = p.Value;
}
}
}
}

internal static ProvisioningHierarchy GetTenantTemplate(Tenant tenant, ExtractConfiguration configuration = null)
{
if (configuration == null)
Expand Down Expand Up @@ -282,14 +305,16 @@ internal void ApplyRemoteTemplate(Web web, ProvisioningTemplate template, Provis
{
using (var scope = new PnPMonitoredScope(CoreResources.Provisioning_ObjectHandlers_Provisioning))
{

web.Context.DisableReturnValueCache = true;

ProvisioningProgressDelegate progressDelegate = null;
ProvisioningMessagesDelegate messagesDelegate = null;
ProvisioningSiteProvisionedDelegate siteProvisionedDelegate = null;
if (provisioningInfo != null)
{
// Apply the configuration parameters to the template
ApplyConfigurationParameters(provisioningInfo.Parameters, template.Parameters);

if (provisioningInfo.OverwriteSystemPropertyBagValues == true)
{
scope.LogInfo(CoreResources.SiteToTemplateConversion_ApplyRemoteTemplate_OverwriteSystemPropertyBagValues_is_to_true);
Expand Down
Loading