I have a service that creates a Sharepoint Online site using CSOM.


This site is created using a defined Template stored in the solutions of the Site Collection. However, the creation of the site can take its time: from 5 minutes to 20 minutes for the site to be ready (all lists created, all views, etc.) Since my ExecuteQuery always returns at 5 minutes (generally with a 503 error) it is impossible for me to know when the site has finished the creation process.

Is there a way to know when the site is available?

I have tried loading the Web object, and even if its not ready, I can load it without problems:

Web sourceWeb = context.Site.OpenWeb(webRelativeUrl);
//this returns the Web even if the site has not finished the creation process

I would like to have something like:

  Thread.Sleep(60000); //60 seconds
  context.Load(web, w => w.IsReady);

However, I can't seem to find any flag or value that can help me for this.

Thank you.

2 Answers 2


Try using ExecuteQueryAsync(), it permits a success and failure handler



        function() {
        function() {

Documentation also See Here

  • Sorry, that’s JavaScript, but C# CSOM has same concepts, methods and members as JavaScript. Documentation for C#: docs.microsoft.com/en-us/previous-versions/office/developer/… Apr 12, 2019 at 13:59
  • The functions needed are from an old assembly for the "Microsoft SharePoint Foundation 2010 Client Object Model for Silverlight". Is it a good idea to add this to my service which only connects to Sharepoint Online? Specially since Silverlight has been out of support for some time now. Apr 12, 2019 at 17:13
  • Ok, I didn't add the extension from Silverlight, however, I did something similar. ExecuteQueryAsync returns the Task object, which then in another function I checked the values of IsCompleted, IsCanceled, and IsFaulted. However, as with the ExecuteQuery, after 5 minutes the Task produces an error because Sharepoint seems to be breaking the connection. Then, I need to find a way to know if the Website has completed, since even if Sharepoint broke the connection, it is still working, which leads me to think that maybe is not Sharepoint but the cloud which is breaking the connection. Apr 12, 2019 at 18:39

Here is how I did my pooling to check if the site is complete :

var tenant = new Tenant(ctx);

var siteCreationProperties = new SiteCreationProperties();

// Create the site collection
var spo = tenant.CreateSite(siteCreationProperties);

// We will need the IsComplete property to check if the provisioning of the Site Collection is complete.
ctx.Load(spo, i => i.IsComplete);
await ctx.ExecuteQueryAsync();

// Check if provisioning of the SiteCollection is complete.
while (!spo.IsComplete)
   // Wait for 3 seconds and then try again
   logger.LogInformation($"Pooling creation site: {input.SiteUrl}");

   await Task.Delay(3000);
   await ctx.ExecuteQueryAsync();

The object Tenant is described there: Microsoft.Online.SharePoint.TenantAdministration.Tenant

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.