Provision classic team sites in a Multi-Geo environment

SharePoint sites can be spread across the default and satellite geo locations of a Multi-Geo tenant. When your custom development (script, app, console application, node.js app, and so on) needs to provision sites, it's important to be aware of the geo locations in your Multi-Geo tenant.

When provisioning classic team site collections (for example, STS#0-based site collections), you need to use the CSOM CreateSite method call as explained and shown in following articles and samples:

The CreateSite method call needs to be executed on an instantiated Tenant object, and a tenant object requires you to specify an SPO Admin center URL to be created.

To create a classic team site:

  1. Determine the geo location that needs to host the site collection (for example, the European satellite).

  2. Use the guidance explained in the article Discover a Multi-Geo tenant configuration to find the tenant admin site and SharePoint root URLs for the geo location.

  3. Create a Tenant object by using the discovered admin site URL.

  4. Use the CreateSite method call to create the site collection.

The following sample shows how to provision a site collection in the European geo location.

// Use the Multi-Geo discovery guidance to discover the tenant admin and root site URLs for this geo location.
string tenantAdminSiteForMyGeoLocation = "https://contoso-europe-admin.sharepoint.com";
string targetUrl = "https://contoso-europe.sharepoint.com/sites/demosite";
string owner = "UserA@contoso.onmicrosoft.com";

using (var ctx = new ClientRuntimeContext(tenantAdminSiteForMyGeoLocation))
{
    ctx.Credentials = adminCredentials;
    
    var tenant = new Tenant(ctx);
    
    //Create new site.
    var newsite = new SiteCreationProperties()
    {
        Url = targetUrl,
        Owner = owner,
        Template = "STS#0",
        Title = title,
        StorageMaximumLevel = 1000,
        StorageWarningLevel = 500,
        TimeZoneId = 7,
    };
    
    var spoOperation = tenant.CreateSite(newsite);
    
    ctx.Load(spoOperation);
    ctx.ExecuteQuery();
    
    while (!spoOperation.IsComplete)
    {
        Thread.Sleep(2000);
        ctx.Load(spoOperation);
        ctx.ExecuteQuery();
        Console.WriteLine("Site creation status: " + (spoOperation.IsComplete ? "waiting" : "complete"));
    }
}

Note

To learn more about the needed permissions and how to configure your applications, see Set up a Multi-Geo sample application.

See also