Class SiteCollection
This class can be used to create modern site collections
Inheritance
Namespace: PnP.Framework.Sites
Assembly: PnP.Framework.dll
Syntax
public static class SiteCollection : object
Methods
AliasExistsAsync(ClientContext, String)
Checks if a given alias is already in use or not
Declaration
public static async Task<bool> AliasExistsAsync(ClientContext context, string alias)
Parameters
Client Context to operate against |
System. Alias to check |
Returns
Task<System. True if in use, false otherwise |
Create(ClientContext, CommunicationSiteCollectionCreationInformation, Int32, Boolean)
Creates a new Communication Site Collection and waits for it to be created
Declaration
public static ClientContext Create(ClientContext clientContext, CommunicationSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, bool noWait = false)
Parameters
Client ClientContext object of a regular site |
Communication information about the site to create |
System. Defines the number of seconds to wait after creation |
System. If specified the site will be created and the process will be finished asynchronously |
Returns
Client ClientContext object for the created site collection |
Create(ClientContext, TeamNoGroupSiteCollectionCreationInformation, Int32, Boolean)
Creates a new Team Site Collection with no group and waits for it to be created
Declaration
public static ClientContext Create(ClientContext clientContext, TeamNoGroupSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, bool noWait = false)
Parameters
Client ClientContext object of a regular site |
Team information about the site to create |
System. Defines the number of seconds to wait after creation |
System. If specified the site will be created and the process will be finished asynchronously |
Returns
Client ClientContext object for the created site collection |
Create(ClientContext, TeamSiteCollectionCreationInformation, Int32, Boolean, String, AzureEnvironment)
Creates a new Team Site Collection and waits for it to be created
Declaration
public static ClientContext Create(ClientContext clientContext, TeamSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, bool noWait = false, string graphAccessToken = null, AzureEnvironment azureEnvironment = default(AzureEnvironment))
Parameters
Client ClientContext object of a regular site |
Team information about the site to create |
System. Defines the number of seconds to wait after creation |
System. If specified the site will be created and the process will be finished asynchronously |
System. An optional Access Token for Microsoft Graph to use for creeating the site within an App-Only context |
Azure Defines the Azure Cloud Deployment. This is used to determine the MS Graph EndPoint to call which differs per Azure Cloud deployments. Defaults to Production (graph.microsoft.com). |
Returns
Client ClientContext object for the created site collection |
CreateAsync(ClientContext, CommunicationSiteCollectionCreationInformation, Int32, Boolean)
Creates a new Communication Site Collection
Declaration
public static async Task<ClientContext> CreateAsync(ClientContext clientContext, CommunicationSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, bool noWait = false)
Parameters
Client ClientContext object of a regular site |
Communication information about the site to create |
System. Defines the number of seconds to wait after creation |
System. If specified the site will be created and the process will be finished asynchronously |
Returns
Task<Client ClientContext object for the created site collection |
CreateAsync(ClientContext, TeamNoGroupSiteCollectionCreationInformation, Int32, Boolean)
Creates a new Team Site Collection with no group
Declaration
public static async Task<ClientContext> CreateAsync(ClientContext clientContext, TeamNoGroupSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, bool noWait = false)
Parameters
Client ClientContext object of a regular site |
Team information about the site to create |
System. Defines the number of seconds to wait after creation |
System. If specified the site will be created and the process will be finished asynchronously |
Returns
Task<Client ClientContext object for the created site collection |
CreateAsync(ClientContext, TeamSiteCollectionCreationInformation, Int32, Int32, Int32, Boolean, String, AzureEnvironment)
Creates a new Modern Team Site Collection (so with an Office 365 group connected)
Declaration
public static async Task<ClientContext> CreateAsync(ClientContext clientContext, TeamSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, int maxRetryCount = 12, int retryDelay = null, bool noWait = false, string graphAccessToken = null, AzureEnvironment azureEnvironment = default(AzureEnvironment))
Parameters
Client ClientContext object of a regular site |
Team information about the site to create |
System. Defines the number of seconds to wait after creation |
System. Maximum number of retries for a pending site provisioning. Default 12 retries. |
System. Delay between retries for a pending site provisioning. Default 10 seconds. |
System. If specified the site will be created and the process will be finished asynchronously |
System. An optional Access Token for Microsoft Graph to use for creeating the site within an App-Only context |
Azure Defines the Azure Cloud Deployment. This is used to determine the MS Graph EndPoint to call which differs per Azure Cloud deployments. Defaults to Production (graph.microsoft.com). |
Returns
Task<Client ClientContext object for the created site collection |
CreateTeamSiteViaGraphAsync(ClientContext, TeamSiteCollectionCreationInformation, Int32, Int32, Int32, Boolean, String, AzureEnvironment)
Creates a new Modern Team Site Collection (so with an Office 365 group connected) using Microsoft Graph
Declaration
public static async Task<ClientContext> CreateTeamSiteViaGraphAsync(ClientContext clientContext, TeamSiteCollectionCreationInformation siteCollectionCreationInformation, int delayAfterCreation = 0, int maxRetryCount = 12, int retryDelay = null, bool noWait = false, string graphAccessToken = null, AzureEnvironment azureEnvironment = default(AzureEnvironment))
Parameters
Client ClientContext object of a regular site |
Team information about the site to create |
System. Defines the number of seconds to wait after creation |
System. Maximum number of retries for a pending site provisioning. Default 12 retries. |
System. Delay between retries for a pending site provisioning. Default 10 seconds. |
System. If specified the site will be created and the process will be finished asynchronously |
System. An optional Access Token for Microsoft Graph to use for creeating the site within an App-Only context |
Azure Defines the Azure Cloud Deployment. This is used to determine the MS Graph EndPoint to call which differs per Azure Cloud deployments. Defaults to Production (graph.microsoft.com). |
Returns
Task<Client ClientContext object for the created site collection |
DeleteSiteAsync(ClientContext)
Deletes a Communication site or a Group-less Modern team site.
Declaration
public static async Task<bool> DeleteSiteAsync(ClientContext context)
Parameters
Client Context to operate against |
Returns
Task<System.
|
EnableCommunicationSite(ClientContext)
Turns a team site into a communication site
Declaration
public static async Task EnableCommunicationSite(ClientContext context)
Parameters
Client ClientContext of the team site to update to a communication site |
Returns
Task
|
EnableCommunicationSite(ClientContext, Guid)
Turns a team site into a communication site
Declaration
public static async Task EnableCommunicationSite(ClientContext context, Guid designPackageId)
Parameters
Client ClientContext of the team site to update to a communication site |
Guid
designPackageId
Design package id to be applied, 96c933ac-3698-44c7-9f4a-5fd17d71af9e (Topic = default), 6142d2a0-63a5-4ba0-aede-d9fefca2c767 (Showcase) or f6cc5403-0d63-442e-96c0-285923709ffc (Blank) |
Returns
Task
|
GetGroupInfo(ClientContext, String)
Checks if a given alias is already in use or not
Declaration
public static async Task<Dictionary<string, string>> GetGroupInfo(ClientContext context, string alias)
Parameters
Client Context to operate against |
System. Alias to check |
Returns
Task<Dictionary<System. True if in use, false otherwise |
GetGroupInfoAsync(ClientContext, String)
Checks if a given alias is already in use or not
Declaration
public static async Task<Dictionary<string, string>> GetGroupInfoAsync(ClientContext context, string alias)
Parameters
Client Context to operate against |
System. Alias to check |
Returns
Task<Dictionary<System. True if in use, false otherwise |
GetGroupInfoByGroupIdAsync(ClientContext, String)
Gets group alias information by group Id
Declaration
public static async Task<Dictionary<string, object>> GetGroupInfoByGroupIdAsync(ClientContext context, string groupId)
Parameters
Client Context to operate against |
System. Id of the group |
Returns
Task<Dictionary<System. True if in use, false otherwise |
GetIsAliasAvailableAsync(ClientContext, String)
Allows validation if the provided alias
is valid to be used to create a new site collection
Declaration
public static async Task<bool> GetIsAliasAvailableAsync(ClientContext context, string alias)
Parameters
Client SharePoint ClientContext to use to communicate with SharePoint |
System. The alias to check for availability |
Returns
Task<System. True if the provided alias is available to be used, false if it is not |
GetValidSiteUrlFromAliasAsync(ClientContext, String)
Checks if the provided alias
is valid to be used to create a new site collection and will return an alternative available proposal if it is not. Use Get
Declaration
public static async Task<string> GetValidSiteUrlFromAliasAsync(ClientContext context, string alias)
Parameters
Client SharePoint ClientContext to use to communicate with SharePoint |
System. The alias to check for availability |
Returns
Task<System. The full SharePoint URL proposed to be used. If that URL ends with the alias you provided, it means it is still available. If its not available, it will return an alternative proposal to use. |
GroupifyAsync(ClientContext, TeamSiteCollectionGroupifyInformation)
Groupifies a classic team site by creating a group for it and connecting the site with the newly created group
Declaration
public static async Task<ClientContext> GroupifyAsync(ClientContext clientContext, TeamSiteCollectionGroupifyInformation siteCollectionGroupifyInformation)
Parameters
Client ClientContext object of a regular site |
Team information about the site to create |
Returns
Task<Client ClientContext object for the created site collection |
HideTeamifyPromptAsync(ClientContext)
Hide the teamify prompt/banner displayed in O365 group connected sites
Declaration
public static async Task<bool> HideTeamifyPromptAsync(ClientContext context)
Parameters
Client ClientContext of the site to operate against |
Returns
Task<System.
|
IsTeamifyPromptHiddenAsync(ClientContext)
Checks if the Teamify prompt/banner is displayed in the O365 group connected sites.
Declaration
public static async Task<bool> IsTeamifyPromptHiddenAsync(ClientContext context)
Parameters
Client ClientContext of the site to operate against |
Returns
Task<System.
|
SetGroupImage(ClientContext, Byte[], String)
Declaration
public static async Task<bool> SetGroupImage(ClientContext context, byte[] file, string mimeType)
Parameters
Client
|
System.
|
System.
|
Returns
Task<System.
|
SetGroupImageAsync(ClientContext, Byte[], String)
Sets the image for an Office 365 group
Declaration
public static async Task<bool> SetGroupImageAsync(ClientContext context, byte[] file, string mimeType)
Parameters
Client Context to operate on |
System. Byte array containing the group image |
System. Image mime type |
Returns
Task<System. true if succeeded |
TeamifySiteAsync(ClientContext, String, AzureEnvironment)
Enable Microsoft Teams team in an O365 group connected team site Will also enable it on a newly Groupified classic site
Declaration
public static async Task<string> TeamifySiteAsync(ClientContext context, string graphAccessToken = null, AzureEnvironment azureEnvironment = default(AzureEnvironment))
Parameters
Client Context to operate against |
System. Graph Access token |
Azure Azure environment to operate |
Returns
Task<System.
|