Graph API can be used to automate the Microsoft Teams lifecycle such as creating teams, channels, adding members, etc.
Refer to this link to see the list of Graph APIs available for Microsoft Teams.
You will see how to retrieve all the teams by calling Graph API in flow.
The list of all teams is here.
In this article, you will see how to perform the following tasks,
- Register an Application in Azure - Register an app in Azure AD and add the required permissions to access the Graph API
- Create flow: Access Teams Graph API Create an Automation Account
Register an application in Azure
Register an application in Azure AD to access the Teams Graph API.
- Navigate to the Azure portal.
- Search for App Registrations. Click App Registrations as shown below.
![Dashboard]()
- Click New Registration.
![App registrations]()
- Enter the Name and click Register.
![Register an application]()
- App registered successfully. In the left navigation, click API Permissions.
![API permission]()
- Click Add a permission.
![Add permissions]()
- Select Microsoft Graph API as shown below.
![Request API permission]()
- Click Application Permissions.
![Request API permission]()
- SelectRead.All permissions and click Add permissions.
![Add permission]()
- Click Grant admin consent.
![Click grant admin consent]()
![Refresh]()
- In the left navigation, click Overview. Copy the Application (client) ID and Directory (tenant) ID values. These values will be used in Flow for authentication.
![Access graph API]()
- In the left navigation, click Certificates & secrets. Click New client secret.
![New client secret]()
- Enter the description and click Add.
![Add a clien secret]()
- Copy the secret value which will be used in flow for authentication.
![New client secret]()
Create Flow
The following trigger (manually starts) and actions will be used in this flow.
![Manually trigger]()
- Navigate to Power Automate portal.
- Create a new flow.
- Trigger: Manually trigger a flow.
![Manually]()
- Action – Initialize Variable (renamed as Directory ID): Copied from App Registration overview page (Directory (tenant) ID) – refer to step 11 in the previous section.
![Directory ID]()
- Action – Initialize Variable (renamed as Application ID): Copied from App Registration overview page (Application (client) ID) – refer to step 11 in the previous section.
![Application ID]()
- Action – Initialize Variable (renamed as Secret): Refer to step 14 in the previous section.
![Secret]()
- Action – Initialize Variable (renamed as URI): Graph API URI - https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&$select=displayName
![URI]()
- List all teams here.
- Action HTTP: Configure HTTP action as shown below.
![Method]()
- Enter the name for the flow and save it.
![Access graph API]()
- Click Test to test the flow. Click Run flow.
![Runflow]()
- Flow ran successfully.
![HTTp]()
- JSON Output:Listed all the teams within the tenant.
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(displayName)",
"value": [
{
"displayName": "M365Chennai"
},
{
"displayName": "Events2020"
},
{
"displayName": "Demo"
},
{
"displayName": "Tech Reads"
},
{
"displayName": "Automation Testing"
}
]
}
Summary
Thus, in this article, you saw how to access Microsoft Teams Graph API in Power Automate.