Created
October 13, 2015 19:46
-
-
Save dgusoff/bd9005d4826fe84089c0 to your computer and use it in GitHub Desktop.
Create new Site Colleciton
This file contains 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
public static void CreateSiteCollection(ClientContext adminContext, string url, string template, string title, string description, int storageLevel, string owner, bool wait) | |
{ | |
var tenant = new Tenant(adminContext); | |
var properties = new SiteCreationProperties() | |
{ | |
Url = url, | |
Owner = owner, | |
Title = title, | |
Template = template, | |
StorageMaximumLevel = storageLevel, | |
UserCodeMaximumLevel = 0 | |
}; | |
//start the SPO operation to create the site | |
SpoOperation op = tenant.CreateSite(properties); | |
adminContext.Load(tenant); | |
adminContext.Load(op, i => i.IsComplete); | |
adminContext.ExecuteQuery(); | |
//check if site creation operation is complete | |
if (wait) | |
{ | |
while (!op.IsComplete) | |
{ | |
Console.WriteLine("Waiting for site at {0}", url); | |
//wait 30seconds and try again | |
System.Threading.Thread.Sleep(30000); | |
op.RefreshLoad(); | |
adminContext.ExecuteQuery(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment