-
Hi, We have recently started using PnPCore to replace our previous CSOM-only SharePoint solutions. We have started building the code to create site collections and have encountered issues relating to the time it takes to get a site collection back, which often takes 15 minutes plus. In the below code, we use the siteCollectionManager to get back the site collection by passing the Url of the created site collection. We do this as the ISiteCollection model returned by the creation doesn't have all the information we want to store. Once we get it back, we create a new instance of a custom model we have defined that cherry-picks the values we need. public async Task<SharePointSiteCollection> GetSiteCollectionWithDetailsAsync(string siteCollectionUrl)
{
var siteCollectionManager = _context.GetSiteCollectionManager();
var newSite = await siteCollectionManager.GetSiteCollectionWithDetailsAsync(new Uri(siteCollectionUrl));
if (newSite == null)
{
return null;
}
return new SharePointSiteCollection(newSite, _context.Web.Id.ToString());
} It's worth noting that we call the above method straight after the site collection has finished provisioning (we previously had a SiteExistsAsync call here as well which returned true) we keep calling it from a higher level in a while loop until it returns our model, so it could simply be the time it takes to add the site collection to the hidden list the method queries. But I wanted to see if people were seeing similar times in their own projects or if there is a different way to go from a ISiteCollection to ISiteCollectionWithDetails that is quicker? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@Cmcclymo : your observation is correct, there's always a delay between creating the site collection and it appearing in the hidden list in tenant admin. Don't know the exact scenario, but when a site collection is created using PnP Core SDK you'll get back a Alternatively you see if using the RenderAdminListData API returns faster (see #1113) => we did not implement this in PnP Core SDK, but please give it a try and provide feedback. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestions, @jansenbe . I've tested with the RenderAdminListData API, and it seems to return a lot quicker, with it taking roughly 2 minutes to create, get and delete the site collection in a unit test compared to the 15 minutes previously seen. I'll mark your response as the answer. |
Beta Was this translation helpful? Give feedback.
@Cmcclymo : your observation is correct, there's always a delay between creating the site collection and it appearing in the hidden list in tenant admin. Don't know the exact scenario, but when a site collection is created using PnP Core SDK you'll get back a
PnPContext
object which you can use to further configure the site collection.Alternatively you see if using the RenderAdminListData API returns faster (see #1113) => we did not implement this in PnP Core SDK, but please give it a try and provide feedback.