diff --git a/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectTeams.cs b/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectTeams.cs index e5e5d7186..059614369 100644 --- a/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectTeams.cs +++ b/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectTeams.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PnP.Framework.Diagnostics; +using PnP.Framework.Graph; using PnP.Framework.Provisioning.Connectors; using PnP.Framework.Provisioning.Model; using PnP.Framework.Provisioning.Model.Configuration; @@ -17,9 +18,8 @@ using System.IO; using System.Linq; using System.Net.Http.Headers; -using System.Text.RegularExpressions; using System.Threading; -using System.Web; +using System.Threading.Tasks; namespace PnP.Framework.Provisioning.ObjectHandlers { @@ -424,7 +424,7 @@ private static string CreateOrUpdateTeamFromGroup(PnPMonitoredScope scope, Team catch (Exception ex) { scope.LogError("Error checking archive status", ex.Message); - } + } } // If the Team is currently archived @@ -496,6 +496,15 @@ private static string CreateOrUpdateTeamFromGroupInternal(PnPMonitoredScope scop wait = false; } } + + // Ensure that Files tab is available right after Teams creation + Task.Run(async () => + { + var graphClient = GraphUtility.CreateGraphClient(accessToken); + + await InitTeamDrive(groupId, graphClient); + }).GetAwaiter().GetResult(); + return (teamId); } @@ -908,7 +917,7 @@ private static string UpdateTeamChannel(Model.Teams.TeamChannel channel, string var channelId = existingChannel["id"].ToString(); var channelDisplayName = existingChannel["displayName"].ToString(); var newChannelName = parser.ParseString(channel.DisplayName); - var identicalChannelName = newChannelName == channelDisplayName; + var identicalChannelName = newChannelName == channelDisplayName; // Prepare the request body for the Channel update var channelToUpdate = new @@ -1761,7 +1770,7 @@ private static List GetTeamChannelTabs(ExtractConfiguration configurati if (string.IsNullOrEmpty(tab.TeamsAppId)) { var tabJObject = teamTabsJObject.FirstOrDefault(x => x["id"].ToString() == tab.ID); - if (tabJObject!=default) + if (tabJObject != default) tab.TeamsAppId = tabJObject["teamsApp"]?["id"]?.ToString(); } tabs.Add(tab); @@ -1777,6 +1786,18 @@ private static string CreateMailNicknameFromDisplayName(string displayName) mailNickname = UrlUtility.ReplaceAccentedCharactersWithLatin(mailNickname); return mailNickname; } - + + public static async Task InitTeamDrive(string GroupId, Microsoft.Graph.GraphServiceClient graphClient = null) + { + var channels = await graphClient.Teams[GroupId].Channels.Request().GetAsync(); + + foreach (var channel in channels) + { + if (channel.DisplayName == "General") + { + await graphClient.Teams[GroupId].Channels[channel.Id].FilesFolder.Request().GetAsync(); + } + } + } } }