How to use Microsoft Graph and Power Automate to Automate Teams Creation With a Template

Often times the issue with the IT Admins is with the ever growing Teams popularity, how to beat the demand and how to create Teams and specially, how to template it out and automate it.

Well, Teams templates are now in the Teams Admin Center where you can see pre-defined templates and the ability to cerate custom templates if required.

With the templates, IT admins have to potentially provide the users the ability create Teams and then advice them to create a Team with a template. This will also give them the opportunity to create more Teams without the knowledge of the IT.

Teams Templates

Microsoft have introduced Teams templates sometime ago so the Admins can use the pre-defined ones or custom ones according to the user requirement. The idea is to bring uniformity across the board.

Template can bundle up Channels, Tabs and Apps

And if you go to a template, it will look like this

Create a Team using a template from a user’s perspective

Problem with the PowerShell new-team cmd-let

You can run the new-team and create a Team, but of you need to create the new team using a template, you will run in to an issue.

This is where you need MS Graph API as it has more access to the components and can control them if you have the right magic-formula 🙂

What you need?

  1. Register Power Automate as an Azure AD App and provide permissions to MS Graph
  2. Pre Defined Teams Templates
  3. Microsoft Forms
  4. Excel Online Workbook
  5. Power Automate

1. Register Power Automate as an Azure AD App

For later activities you need to perform in Power Automate using MS Graph, you ned to make sure Power Automate is registered as an app by providing the consent.

You need Global Admin access to perform this action.

Go to Azure AD portal > App registrations > New Registration > Provide the app name (eg: Power_Automate_Graph_API) Supported Account Types: Accounts in this organizational directory only Press Register


Note down the Client ID of the APP


Grab the Secret

Go to Certificates and Services > New Client Secret > Set the name and expiration period note down the Secret (Value)


Now go to API permissions Go to Add a permission > select MS Graph > select Application permissions

According to the official MS Documentaion, the below permissions requires for the applocation Team.Create, Teamwork.Migrate.All, Group.ReadWrite.All**, Directory.ReadWrite.All**

Once the above permissions are added, provide Admin consent

This completes the app registration and providing MS Graph the necessary permissions.


2. Pre Defined Teams Templates

You can use the pre-defined templates in the Teams Admin Center Teams Admin Center > Teams > Teams Templates

When you open the preffered Template, note down the Templete ID eg:

If you create a new Template according to your requirement (custom template), then the Template ID would look something like this eg: a8643242-c5e5-444d-813b-b191hc3adb71

3. Create a simple Form using Microsoft Forms

You need the below ‘required’ questions in the Form

  1. Team Name
  2. Team Owner
  3. Template Name (drop down)

A bit about the Template Name. This Template name must corralate with the previously noted templates. Ideally if you are planning on using 5 templates, you need to know the Template names and the IDs.


4. Excel Online Workbook

Create a simple Excel Online workbook and add a Table. Name your Table and the columns Eg: Table Name: Table1 Columns: TemplateName, TemplateID

Save the file in a OneDrive or in a Docuemnt Library

4.Power Automate

This is the most interesting part. To create the Power Automate flow by using the above elements. Please check the Solution file for the Power Automate Flow.

How to Create the Power Automate Flow

In this section, I’m discussing the steps involved in creating the Flow.

Step 1 – Create the trigger

This should be When a new responce is submitted and select the previously created MS Form


Step 2 – (Action) Get Response Details


Step 3 – (Action) Search for the user

This correlates with the Qurstion 4 of the form (Team Owner’s First and Last Name or Email (please enter the correct details) The reason is the form is unable to provide user @ mentoins or resolves usernames/ UPNs. With the Search for users (V2) action in place, when you provide a part of the name (given nameor surname) email address, UPN it will search for the user from Azure AD


As you can see in the screenshot, it Search Term should be Team Owner’s name from the Form.

Step 4 – (Action) Get a row

This part correlates with the drop-down question 3 in the form Template Nname 

As per the steps mentioned above, you now have the workbook with the required template IDs in it. Provide the necessary feileds as mentiond above.

Step 5 – (Action) Use HTTP to invoke REST API

As you can see in the below screenshot, for Select an Output from the previous steps and select Value from the Dynamic Content box. 

In the HTTP REST API function, the below information should be filled.

Method : POST


Headers : Content-type application/json

Authentication : Active Directory OAuth

Tenant : Azure AD Tenant ID

Audiance :

Client ID : Client ID from App Registration step

Credential Type : Secret

Secret : Secret Value from above

Body : In the below code you can see [ID], **[TEAM NAME] **and [USER ID]. They are the Dynamic Content I picked from the box acordingly. (See screenshot)


{ “template@odata.bind“: “‘[ID]’)“, “displayName”: “‘[TEAM NAME]'”, “description”: “The team for those in architecture design”, “members”: [ { “@odata.type”: “#microsoft.graph.aadUserConversationMember”, “roles”: [ “owner” ], “user@odata.bind“: “‘[USER ID]’)” } ] }

Once it’s all done, you will be able to automate the Teams creation by ingesting the preferred template


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.