Luckily not all the sessions on the MVP Summit were too exciting, so I had a little time to do my MVP mate Samuel a favor and write a custom connector to create a Microsoft Team via Flow - enjoy Samu :)
The connector does not need any custom code and is only a wrapper for the Microsoft Graph API. It is also useful as an example of how to use the Microsoft Graph API with Flow without writing any code (I don't call a JSON file code ;)
1. Register an App in the Azure Portal
- Register an new Azure AD App in you Azure AD
- Add Microsoft Graph permissions for delegated "Read and write all groups" (Group.ReadWrite.All)
- Save the application id (client id)
- Generate and save a key (app secret)
2. Install the Custom Connector
- Sign in to PowerApps Portal https://web.powerapps.com
- Navigate to custom connectors -> create custom connector -> Import an OpenAPI file
- Enter a title for the connector e.g. "Microsoft Teams Extensions" and choose the teams.swagger.json file from this Git repo -> next
- Verfiy the following settings: Scheme: (x) HTTPS; Host: "graph.microsoft.com"; Base URL "/" and continue
- As authentication type choose "OAuth 2.0"
- Select "Generic Oauth 2" as Identity provider
- Client Id -> paste from step 1
- Client secrret -> paste from step 1
- Authorization URL: "https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/authorize"
- Token URL: "https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/token"
- Refresh URL: "https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/token"
- Scope: "Group.ReadWrite.All"
- Click "Create connector"
- Navigate back to the security tab and copy the "Redirect URL" and register the URL as an "Reply URL" in your Azure AD App within the Azure Portal
3. Try it!
Before you can create a Microsoft Team you have to create Unified Group. Use the "Azure AD - Create Group" action to create Unfified Group and use the ID of this group to create a Microsoft Team for the group.
Hopefully the result will look like this: