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

Fix #3294 - issue with silent teamify error for App-only M365 group creation #3310

Merged
merged 1 commit into from
Jul 29, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed issue with colliding assemblies when using PnP PowerShell with other modules. [#3280](https://github.com/pnp/powershell/pull/3280)
- Fixed issue with `-ArchiveRedirectUrl` parameter not working correctly in `Set-PnPTenant` cmdlet. [#3289](https://github.com/pnp/powershell/pull/3289)
- Fixed `New-PnPAzureADGroup` cmdlet throwing null reference error when owners and members are not specified. [#3308](https://github.com/pnp/powershell/pull/3308)
- Fixed `New-PnPTeamsTeam` cmdlet, it will now throw error if it fails to teamify a Microsoft 365 group.

### Contributors

Expand Down
59 changes: 31 additions & 28 deletions src/Commands/Utilities/TeamsUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,6 @@ public static async Task<Team> NewTeamAsync(string accessToken, PnPConnection co
}
if (group != null)
{
Team team = teamCI.ToTeam(group.Visibility.Value);
var retry = true;
var iteration = 0;
while (retry)
{
try
{
var teamSettings = await GraphHelper.PutAsync(connection, $"v1.0/groups/{group.Id}/team", team, accessToken);
if (teamSettings != null)
{
returnTeam = await GetTeamAsync(accessToken, connection, group.Id);
}
retry = false;
}

catch (Exception)
{
await Task.Delay(5000);
iteration++;
}

if (iteration > 10) // don't try more than 10 times
{
retry = false;
}
}

// Construct a list of all owners and members to add
var teamOwnersAndMembers = new List<TeamChannelMember>();
if (owners != null && owners.Length > 0)
Expand All @@ -248,7 +221,37 @@ public static async Task<Team> NewTeamAsync(string accessToken, PnPConnection co
await GraphHelper.PostAsync(connection, $"v1.0/teams/{group.Id}/members/add", new { values = chunk.ToList() }, accessToken);
}
}

Team team = teamCI.ToTeam(group.Visibility.Value);
var retry = true;
var iteration = 0;
while (retry)
{
try
{
var teamSettings = await GraphHelper.PutAsync(connection, $"v1.0/groups/{group.Id}/team", team, accessToken);
if (teamSettings != null)
{
returnTeam = await GetTeamAsync(accessToken, connection, group.Id);
}
retry = false;
}

catch (Exception)
{
await Task.Delay(5000);
iteration++;
if (iteration > 10)
{
throw;
}
}

if (iteration > 10) // don't try more than 10 times
{
retry = false;
}
}
}
return returnTeam;
}
Expand Down Expand Up @@ -908,7 +911,7 @@ public static async Task<TeamTab> AddTabAsync(PnPConnection connection, string a
case TeamTabType.Planner:
{
tab.TeamsAppId = "com.microsoft.teamspace.tab.planner";
tab.Configuration = new TeamTabConfiguration();
tab.Configuration = new TeamTabConfiguration();
tab.Configuration.ContentUrl = contentUrl;
break;
}
Expand Down
Loading