Create a SharePoint Online Team site using Power Automate (Group connected and non-group connected)

In this Power Automate tutorial, I will show you, how to create a SharePoint Online team site using Power Automate. We will create a SharePoint group-connected team site and a nongroup-connected team site using Power Automate.

Also, we will see how we can set storage limits and add members to both of the Team sites.

Recently, I got a requirement while working for a client, to create a SharePoint Team site, set the storage limit, and add members to the SharePoint site. Basically, the team site we have created:

  • Group connected team site
  • Non-group connected team site

For a group-connected team site, first, we will create an instant cloud flow, and then we will do the rest API calls to create the Microsoft Office 365 group. Then we will add members to it using group id.

As we know SharePoint team site is associated with group connected team site. So, we will fetch the site id and Site URL using the graph API call. Then using site id and site URL we set the storage limit.

And for nongroup connected team sites, we will create an instant cloud flow, that will do the rest API call to create the site. Then we will set the storage limit and Storage warning limit using the Site id and Site URL. After that, we will get the group id to add the members to the SharePoint site using the rest API call.

Now in Power Automate, we will create:

  • Group connected team site
Create Microsoft office 365 group connected team site using power automate
  • Non-group connected team site
How to create non group connected team site using Power automate

Also, you can check, Create a SharePoint Online Communication Site using Power Automate.

Create Group connected SharePoint team site using Power Automate

Here we will see how to create a SharePoint Team site group connected using Power Automate. Then we will add members to the group and set the storage limit of the SharePoint site.

Follow the below steps to create Group connected SharePoint team site using Power Automate.

Step 1: Create an Instant cloud flow

Logged in to Power Automate, and then click on + Create -> select Instant Cloud Flow.

Create group connected team site using Power automate
Create group connected team site using Power automate

Then provide the Flow name, and select ‘Manually trigger Flow’ as a trigger action-> click on Create.

Create group connected team site using Power automate instant cloud flow

Now you can see the Manually trigger a flow action is added to the flow.

How to create group connected team site using Power automate instant cloud flow

Step 2: Create Office 365 group using the graph API call

To create Office 365 group using a Microsoft graph API call, we need to provide the below information related to the group:

  • “displayName”: Specifies the Office 365 group’s display name. It is set to “Morgan Stanley Projects” in this example.
  • “mailEnabled”: Indicates whether or not the group is mail-enabled. When set to true, the group is able to receive and send emails.
  • “mailNickname”: Specifies the group’s email nickname. It serves as a unique identifier for the email address of the organization. It is set to “morgan-stanley-projects” in this example.
  • “securityEnabled”: Indicates whether the group is secure. When set to false, this indicates that the group is not a security group.
  • “groupTypes”: Specifies the group’s types. It is set to a single value of “Unified” in this case, indicating a Microsoft 365 group.

So, click on +New step -> select Send an HTTP request action (Office 365 group). Then provide the below information:

  • Uri: Provide the URI for the request, which is the endpoint for creating Office 365 groups in Microsoft Graph API.
  • Method: Choose the method as POST, as we are creating the Office 365 group.
  • Body: Provide the below code, which is the information for Office 365 group.
{
  "displayName": "Morgan Stanley Projects",
  "mailEnabled": true,
  "mailNickname": "morgan-stanley-projects",
  "securityEnabled": false,
  "groupTypes": [
    "Unified"
  ]
}
  • Content-Type: Provide ‘application/json’, it specify the content type of the request.
Create SharePoint group connected team site using Power automate
Create a SharePoint group connected team site using Power automate

Step 3: Add members to the group

To add members to the SharePoint group, we need a group id. To get the group id from the above step we will use the Parse json action.

So, click on the +New step -> then select the Parse json action -> provide the below information.

  • Content: Select Body – Send an HTTP request, from the dynamic content.
  • Schema: To get the schema, click on Generate From Sample button -> then provide the json of the output of the above HTTP request action.
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups/$entity",
  "id": "d619e6fb-a767-41bc-86ef-95b6ceb86a8b",
  "deletedDateTime": null,
  "classification": null,
  "createdDateTime": "2023-06-06T13:28:59Z",
  "creationOptions": [],
  "description": null,
  "displayName": "Morgan Stanley Projects",
  "expirationDateTime": null,
  "groupTypes": [
    "Unified"
  ],
  "isAssignableToRole": null,
  "mail": "[email protected]",
  "mailEnabled": true,
  "mailNickname": "morgan-stanley-projects",
  "membershipRule": null,
  "membershipRuleProcessingState": null,
  "onPremisesDomainName": null,
  "onPremisesLastSyncDateTime": null,
  "onPremisesNetBiosName": null,
  "onPremisesSamAccountName": null,
  "onPremisesSecurityIdentifier": null,
  "onPremisesSyncEnabled": null,
  "preferredDataLocation": null,
  "preferredLanguage": null,
  "proxyAddresses": [
    "SMTP:[email protected]"
  ],
  "renewedDateTime": "2023-06-06T13:28:59Z",
  "resourceBehaviorOptions": [],
  "resourceProvisioningOptions": [],
  "securityEnabled": false,
  "securityIdentifier": "S-1-12-1-3592021755-1102882663-3063279494-2339027150",
  "theme": null,
  "visibility": "Public",
  "onPremisesProvisioningErrors": []
}

Once we have the group id, we can add members to the Office 365 group using Power Automate.

See also  SharePoint Online List Permissions [Complete tutorial]

So, click on the +New step -> select the ‘Add member to group‘ action. Then provide the below information:

  • Group Id: Provide the group id-parse json from the dynamic content.
  • User Principal name: provide the user principal name of the member you want to add as group id.
Create Microsoft office 365 group connected team site using Microsoft power automate

It will take some time to create the group and add members to it, so I have used the Delay action. It will delay the flow for 30 seconds.

How to Create Microsoft office 365 group connected team site using Microsoft power automate

Now we will move forward to set the Storage limit of the SharePoint site.

Step 4: Set the Storage limit

As we know when we create an Office 365 group, the SharePoint site is associated with it.

We will get the site URL and site id, by using this we will set the Storage limit for the SharePoint site.

So, first, we will get the site URL, click on the +New step -> select Send an HTTP request to SharePoint action. Then provide the below information

  • Site address: Provide the SharePoint administrator address.
  • Method: Choose to GET, as we fetch the Site URL of the SharePoint site.
  • Uri: Provide the API as ‘_api/SP.Directory.DirectorySession/Group(‘@{body(‘Parse_JSON_5’)?[‘id’]}’)/SiteUrl’ to fetch the site URL.

To get the site URL in the dynamic content of Power Automate flow, we will use the Parse json action. So, click on + New step -> select Parse json action, then provide the below information.

  • Content: Select the Body – Send an HTTP request to SharePoint-Get site URL, from the dynamic content.
  • Schema: To add schema, click on ‘Generate from sample’, and then add the output json of the above action. Then click on Done. Now you can see the schema is generated.
{
  "d": {
    "siteUrl": "https://tsinfotechnologies.sharepoint.com/sites/morgan-stanley-projects"
  }
}
How to Create Microsoft office 365 group connected team site using power automate

Next, we need the Site id, so click on +New step -> select Send an Http request to SharePoint action, and provide the below information:

  • Site address: Provide the Site Url -parse json, from the dynamic content.
  • Methods: Choose GET method as we are fetching the SharePoint site id
  • Uri: Provide the API as ‘_api/site?$select=Id‘ to get the site id of the SharePoint site.
  • Headers: Provide the below code as we need accept and content type to do the rest API call.
{
  "accept": "application/json;odata=nometadata",
  "content-type": "application/json;odata=nometadata"
}

Now we will set the storage limit of the SharePoint site, so click on +New step -> select the ‘Send an HTTP to SharePoint ‘ action. Then provide the below information:

  • Site Address: Select or provide the SharePoint Admin center address
  • Method: Select POST, we are providing the storage limit.
  • Uri: Provide the Uri as ‘_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/Sites(‘@{outputs(‘Send_an_HTTP_request_to_SharePoint-_Get_site_id’)?[‘body’][‘Id’]}’))’, we are doing API calls to that site to set the storage limit of the site.
  • Headers: Provide like the below code example (There are required while you are calling a rest API call).
{
  "Accept": "application/json;odata=nometadata",
  "Content-Type": "application/json;odata=nometadata",
  "X-HTTP-Method": "MERGE"
}
  • Body: Provide the below code example (There are required while you are calling a rest API call)to set the storage limit. Also, you can change the storage based on your requirement.
{
"StorageMaximumLevel": "56000",
"StorageWarningLevel": "12340"
}
How to Create Microsoft office 365 group connected team site using microsoft flow

Now our Flow is ready to go, so you can test the flow, and every time changes the display name, and mail nickname.

Step 5: Run the Flow

To run the flow, click on the Test icon -> select the Manually option -> Then click on the Test button.

How to Create SharePoint group connected team site using Power automate

 Next, connect to the credential, and then click on the Continue button -> Next click on the Run Flow button -> click on Done.

See also  How to Convert String to Float in Power Automate?

After that, you can see your flow ran successfully in Power Automate.

to Create SharePoint group connected team site using Power automate

Now, we will check whether the Office 365 group is created and members is added to it.

So, Microsoft 365 admin center, click on Teams and Groups -> select Active teams and Groups. Here you can see the group and all the information related to groups. Under ‘Site info’ you can see the site address and Storage limit.

to Create SharePoint group connected team site using Microsoft Power automate

This is how to create a group connected SharePoint Online team site using Power Automate

Non-group Connected SharePoint team site using Power Automate

Here we will see how to create a non-group connected SharePoint Online team site using Power Automate.

Follow the below steps to create a non-group connected SharePoint team site using Power Automate

Step 1: Create an Instant Cloud Flow

Logged in to Power Automate, and then click on + Create -> select Instant Cloud Flow.

create non group connected team site in SharePoint using Microsoft flow

Then provide the Flow name, and select ‘Manually trigger Flow’ as a trigger action-> click on Create.

How to create non group connected team site using Power automate

Now you can see a Manually trigger flow, is added to the flow.

How to create a non group connected team site in SharePoint Online with rest api call using Power automate

Next, we will create a team site in SharePoint using Rest API call.

Step 2: Create a Team site in SharePoint

Now we will create a SharePoint non-group connected team site with a rest API call. We need to provide the below site information

  • Title“: Provide the title or name of the team site.
  • Url“: Provides the URL where the team site will be created.
  • Description“: Provides a description or brief information about the team site.
  • Owner“: Provide the owner or administrator of the team site.
  • Lcid“: Provides the language code identifier (LCID)as 1033, which indicates the English language.
  • WebTemplate“: – Provide the templates as “STS#3” to be used for creating the team site.
  • SiteDesignId“: “@{guid()}” – This is an expression that generates a unique identifier (GUID) for the site design.
  • ShareByEmailEnabled“: In this case, it is set to “true,” which means sharing via email will be enabled.

Click on the +New step-> select Send an HTTP request to SharePoint action -> then provide the information:

  • Site address: Provide the SharePoint tenant address
  • Method: Select the POST method, as we are creating the SharePoint site.
  • Uri: Provide the API as “_api/SPSiteManager/create”
  • Headers: Provide the Header as the below code, as we need to accept and content type while creating SharePoint sites.
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  • Body. In the body provide the json code which contains the site information.
{
	"request": {
		"Title": "Morgans' Dev team",
		"Url": "https://tsinfotechnologies.sharepoint.com/sites/morgans-dev-team",
		"Description": "This is a team site",
		"Owner": "[email protected]",
		"Lcid": 1033,
		"WebTemplate": "STS#3",
		"SiteDesignId": "@{guid()}",
		"ShareByEmailEnabled": true
	}
}
create non group connected SharePoint team site using Microsoft Power Automate

Step 3: Set Storage limit

To set the storage limit we need the site URL and site id. For this click on +New step -> select Parse json action. Then provide the below information.

  • Content: Select the Body from the dynamic content.
  • Schema: To add schema, click on Generate from sample button, then provide the below output Json code of the above rest API step to create the site.
{
  "d": {
    "Create": {
      "__metadata": {
        "type": "Microsoft.SharePoint.Portal.SPSiteCreationResponse"
      },
      "SiteId": "42a7d672-77f6-4d04-8012-68a1dbeedbee",
      "SiteStatus": 2,
      "SiteUrl": "https://tsinfotechnologies.sharepoint.com/sites/morgans-dev-team"
    }
  }
}
how to create non group connected SharePoint team site using Microsoft Power Automate

Next, we will set the storage limit of the SharePoint site. So click on +New step -> Send an HTTP request to SharePoint. Then provide the below information.

  • Site Address: Select or provide the Site URL. In this case select the site URL, from the dynamic content
  • Method: Select POST, we are providing the storage limit.
  • Uri: Provide the Uri as ‘_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/Sites(‘@{outputs(‘Send_an_HTTP_request_to_SharePoint-_Get_site_id’)?[‘body’][‘Id’]}’))’, we are doing API calls to that site to set the storage limit of the site.
  • Headers: Provide like the below code example (There are required while you are calling a rest API call).
{

  "Accept": "application/json;odata=nometadata",

  "Content-Type": "application/json;odata=nometadata",

  "X-HTTP-Method": "MERGE"

}

Body: Provide the below code example (There are required while you are calling a rest API call)to set the storage limit. Also, you can change the storage based on your requirement.

{
"StorageMaximumLevel": "2560",
"StorageWarningLevel": "1260"
}
how to create non group connected SharePoint team site using Microsoft flow

Step 4: Add members to the Site

To add members to the SharePoint Team site, we need a group id, for this first, we will fetch the group id from the SharePoint site. Then parsed the json output that will reflect in the dynamic content.

See also  How to create a Measure based on Slicer in Power BI

So, click on +New step -> select ‘Send an HTTP request to SharePoint‘ .Then provide the below information:

  • Site address: Select the site URL from the dynamic content
  • Method: Select the GET method, because we are fetching the group id from the site
  • Uri: Provide the “_api/web?$select=AssociatedMemberGroup/Id&$expand=AssociatedMemberGroup” , to get the group id
  • Headers: Provide the headers like the ones below, which are required to do the rest API calls.
{
  "Accept": "application/json;odata=nometadata"
}
create non group connected team site using Microsoft Power Automate

Next, click on +New step -> select Parse json action, then provide the below information:

  • Content: Select the Body from the dynamic content, from the previous step.
  • Schema: To get the schema, click on ‘Generate from sample‘, and then provide the json code of the output of the above step.
{
  "AssociatedMemberGroup": {
    "Id": 5
  }
}
create non group connected team site using Microsoft flow

Now we will add members to the SharePoint site, so click on the +New step -> select Send an HTTP request to SharePoint action. Then provide the below information:

  • Site address: Select the Site URL from the dynamic content.
  • Method: Select the POST method, as we are adding members to the SharePoint site.
  • Uri: Provide the API as ‘/api/web/sitegroups/getById(@{body(‘Parse_JSON-_Group_Id_3′)?[‘AssociatedMemberGroup’]?[‘Id’]})/users’ , to add the members to the SharePoint site.
  • Headers: Provide the headers like below, to do the rest API call we need Accept and content-type.
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  • Body: In the body, provide the below json code to add a member to the SharePoint site.
{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "i:0#.f|membership|<provide the member email>"
}
create non group connected SharePoint team site using Microsoft flow

Now our Flow is ready to go, so you can test the flow, and every time change the site name, and alias in Url.

Step 5: Run the Flow

To run the flow, save the flow and click on the Test icon, -> Manually -> click on the Test button. Next, connect to the credential, and then click on the Continue button -> Next click on the Run Flow button -> click on Done.

You can see your Flow run successfully, we can check our flow in the Active Sites in the SharePoint admin center.

create non group connected team site in SharePoint using Microsoft Power Automate

After that in the SharePoint Admin center, you can check the storage limit and members are added to it.

create no group connected team site in SharePoint using Microsoft Power Automate

Download a Complete Package

You can download a complete package where we have created a flow using Power Automate, where users can request a SharePoint site by filling out a form. Users will fill out a SharePoint list form by adding the below details:

  • Site Title (Single line of text)
  • Site Owner (Person)
  • Alias (Single line of text)
  • Site URL (Hyperlink)
  • Site description (Multi-line of text)
  • Site member (Person)
  • Max Storage (Number)
  • Max storage warning limit (Number)

Once the request is received, the first thing the flow will check is the site storage, if a user requested more than 50GB of storage, then it will go for approval to a concerned approver.

Else it will create a SharePoint site and send an email to the Site Owners with the Site Details.

Currently, the flow supports 3 types of sites:

  • SharePoint Online communication site
  • SharePoint Online Team site (Office 365/Microsoft 365 Group connected)
  • SharePoint Online Team site (Without Office 365/Microsoft 365 Group connected)

Conclusion

In this Power Automate tutorial, I have explained, how to create a SharePoint Online team site using Power Automate. Here we saw, how a user can create Office 365 group-connected team site and no Office 365 group-connected team site in SharePoint Online using Power Automate.

After that, we saw how to set a storage limit and add members to both group-connected and non-group connected SharePoint Online team site using Power Automate.

You may also like:

>