cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blanghorst
Helper IV
Helper IV

Creating a site collection with Power Automate

I've seen this question asked before, but the answers posted always seem incorrect.    For example, in the article below, the user asks how to create a site collection but the proposed solution creates a SUBSITE - in Office 365, there is a HUGE difference:

 

https://powerusers.microsoft.com/t5/General-Power-Automate/Create-Site-Collection/m-p/294258#M28790

 

Most answers I've seen make a similar error or advise using Azure functions to run a Powershell script to provision the site collection.   What I'd like to know is the following:

 

1.  Has anyone triggered a PowerShell script running in an Azure function from Power Automate which provisions a site collection?  Not a subsite - a *site collection.*

2.  Based on what I'm seeing, I don't see a way to create the site collection via Power Automate directly via a REST connection.  Is that true?

3.  Plumsail makes Plumsail Actions and it has a lot of cool activities, including an activity to deploy modern sites - which deploys an actual site collection.  Does anyone have experience with these activities?

1 ACCEPTED SOLUTION

Accepted Solutions
blanghorst
Helper IV
Helper IV

I'm going to go ahead and post the proper ( 🙂 ) solution to this question in case anyone asks in the future.  You CAN create a site collection from Flow very easily.    First, an article on creating modern sites with REST:

 

https://docs.microsoft.com/en-us/sharepoint/dev/apis/site-creation-rest

 

Second, implementation in Power Automate:

Flow.jpg

 

This creates a new site collection!  In my example above, I have it triggered from a manual Flow from a list item, but you can trigger it any other way as well.   You can also associate the site with a hub site using an additional REST call - details here:

 

https://docs.microsoft.com/en-us/sharepoint/dev/features/hub-site/rest-joinhubsite-method

 

You can deploy a site with any site design in your tenant.  

View solution in original post

12 REPLIES 12
blanghorst
Helper IV
Helper IV

I'm going to go ahead and post the proper ( 🙂 ) solution to this question in case anyone asks in the future.  You CAN create a site collection from Flow very easily.    First, an article on creating modern sites with REST:

 

https://docs.microsoft.com/en-us/sharepoint/dev/apis/site-creation-rest

 

Second, implementation in Power Automate:

Flow.jpg

 

This creates a new site collection!  In my example above, I have it triggered from a manual Flow from a list item, but you can trigger it any other way as well.   You can also associate the site with a hub site using an additional REST call - details here:

 

https://docs.microsoft.com/en-us/sharepoint/dev/features/hub-site/rest-joinhubsite-method

 

You can deploy a site with any site design in your tenant.  

View solution in original post

is there a way to package this so that it auto associates with a hub site?

Yes, the second link in my post describes that process.

Yes I followed that, however it times out with BadGateway. Basically I have a process in which a site is created based on a list. That portion is fine.

 

The associating with a hub site is what keeps failing

 

    "parameters": {
        "dataset": "https://domain.sharepoint.com/sites/Test",
        "parameters/method": "POST",
        "parameters/uri": "/_api/site/JoinHubSite('##########')",
        "parameters/headers": {
            "Accept": "application/json;odata=verbose\n",
            "Content-Type": "application/json;odata=verbose;charset=utf-8\n"
  

If you're putting the hub site REST call as the step after the site creation, you should add a delay between the two steps.  I create my site, have a delay activity (I arbitrarily put 5 minutes), and then perform the hub site REST call.  Mine works fine that way.

Thank you!

Thanks @blanghorst .

Can you confirm that, the user/flow connection needs SharePoint admin/ Global Admin rights on tenant right.?

Can this be done by a regular user with his permissions elevation like RunWithElevatedPrivileges in Server Object Model and app-only permission in Provider Hosted model in On-premise environment.

 

Thanks

Purna

I haven't tested it with a standard user because I ended up not needing it.  However, my guess is that if site creation is enabled for users (which I believe is the default), this would likely work for a standard user.  You could also potentially run the creation steps in the flow using an account which does have the proper permissions.

Thank you @blanghorst  for quick response.   I will give a test on my end.

 

Regards

Purna

Abhishek4
New Member

Any idea, if we can set external sharing using the same way?

I would have to research that.  I'm pretty sure it is possible but don't know off the top of my head. 

robertmsawyer
Regular Visitor

Has anyone been successful in setting up guest access when the site collection is created?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,708)