Created
September 30, 2015 13:36
-
-
Save wictorwilen/9ef361b7d510c229d8fc to your computer and use it in GitHub Desktop.
SPO Create Site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SpoOperation op = _tenant.CreateSite(_newsite); | |
ctx.Load(_tenant); | |
ctx.Load(op, i => i.IsComplete); | |
try { | |
ctx.ExecuteQuery(); | |
} | |
catch (ServerException se) | |
{ | |
if(se.ServerErrorCode != -2146233083) | |
{ | |
throw; | |
} | |
timeout_detected = true; | |
} | |
catch (WebException we) | |
{ | |
if(we.Status != WebExceptionStatus.Timeout) | |
{ | |
throw; | |
} | |
timeout_detected = true; | |
} | |
while (timeout_detected || !op.IsObjectPropertyInstantiated("IsComplete") || !op.IsComplete ) | |
{ | |
op.RefreshLoad(); | |
timeout_detected = false; | |
try | |
{ | |
// Use this as a keep alive (instead of increasing WEBJOBS_IDLE_TIMEOUT), also cannot have Infinite timeout | |
Log.Info("Provisioning.Common.Office365SiteProvisioningService.CreateSiteCollection", | |
"Waiting for Site Collection to be created...."); | |
ctx.ExecuteQuery(); | |
} | |
catch (ServerException se) | |
{ | |
if (se.ServerErrorCode != -2146233083) | |
{ | |
throw; | |
} | |
timeout_detected = true; | |
} | |
catch (WebException we) | |
{ | |
if (we.Status != WebExceptionStatus.Timeout) | |
{ | |
throw; | |
} | |
timeout_detected = true; | |
} | |
//wait 30seconds and try again | |
System.Threading.Thread.Sleep(30000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment