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.
- Click New Registration.
- Enter the Name and click Register.
- App registered successfully. In the left navigation, click API Permissions.
- Click Add a permission.
- Select Microsoft Graph API as shown below.
- Click Application Permissions.
- SelectRead.All permissions and click Add permissions.
- Click Grant admin consent.
- 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.
- In the left navigation, click Certificates & secrets. Click New client secret.
- Enter the description and click Add.
- Copy the secret value which will be used in flow for authentication.
Create Flow
The following trigger (manually starts) and actions will be used in this flow.
- Navigate to Power Automate portal.
- Create a new flow.
- Trigger: Manually trigger a flow.
- Action – Initialize Variable (renamed as Directory ID): Copied from App Registration overview page (Directory (tenant) ID) – refer to step 11 in the previous section.
- Action – Initialize Variable (renamed as Application ID): Copied from App Registration overview page (Application (client) ID) – refer to step 11 in the previous section.
- Action – Initialize Variable (renamed as Secret): Refer to step 14 in the previous section.
- Action – Initialize Variable (renamed as URI): Graph API URI - https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&$select=displayName
- List all teams here.
- Action HTTP: Configure HTTP action as shown below.
- Enter the name for the flow and save it.
- Click Test to test the flow. Click Run flow.
- Flow ran successfully.
- 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.