在多地理位置环境中预配经典团队网站

可以将 SharePoint 网站推广到多地理位置租户中的默认和附属地理位置。 如果你的自定义开发(脚本、应用、控制台应用、node.js 应用等)需要预配网站,请务必注意多地理位置租户中的地理位置。

预配经典团队网站集(例如,基于 STS#0 的网站集)时,需要使用 CSOM CreateSite 方法调用,如下面的文章和示例所述/所示:

需要对实例化的 Tenant 对象执行 CreateSite 方法调用,并且租户对象需要你指定要创建的 SPO 管理中心 URL。

若要创建经典团队网站:

  1. 确定需要托管网站集的地理位置(例如,欧洲附属地理位置)

  2. 根据《发现多地理位置租户配置》一文中的指南,查找地理位置的租户管理网站和 SharePoint 根网站 URL。

  3. 使用发现的管理网站 URL 创建 Tenant 对象。

  4. 使用 CreateSite 方法调用创建网站集。

下面的示例展示了如何在欧洲地理位置预配网站集:

// 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"));
    }
}

注意

若要详细了解所需权限以及如何配置应用,请参阅设置多地理位置示例应用程序

另请参阅