Мicrosoft Flow: Creating a Microsoft Team

Microsoft Flow [1] has become a valuable asset to businesses all around the world that are using Office 365 to work more productively, creatively and securely, regardless if their members are at the office, at a conference in another country or simply at home.

With Flow businesses can connect their Office 365 apps and services in an automated manner. No matter if you need a workflow between SharePoint and Outlook or Dropbox and Slack or even Twitter and Dynamics 365, it all can be accomplished – with Flow there are thousands of possibilities. In this way, you save valuable time by automating team notifications, file synchronization, data analysis and more.

Recently, many have asked:

But how can you create a Team by using Flow?

At this time, there is no available Action in Flow that can do that. Therefore, a Custom Connector should be used instead [2].

Creating a Custom Connector

To create the connector there is no need of any code. Instead, a wrapper for the Microsoft Graph API can be used in the form of an Open API 2.0 specification [2]. The following code is the needed json file, made available by Christian Glessner [2].

{
    "swagger": "2.0",
    "info": {
      "title": "Microsoft Teams Extension CC",
      "description": "Things that Microsoft has forgotten - Create a Microsoft Team",
      "version": "1.0"
    },
    "host": "graph.microsoft.com",
    "basePath": "/",
    "schemes": [
      "https"
    ],
    "consumes": [],
    "produces": [],
    "paths": {
      "/beta/groups/{id}/team": {
        "put": {
          "responses": {
            "default": {
              "description": "default",
              "schema": {
                "type": "string"
              }
            }
          },
          "summary": "Create a Microsoft Team",
          "description": "Create a Microsoft Team for an existing Office 365 Group",
          "operationId": "CreateTeam",
          "parameters": [
            {
              "name": "id",
              "in": "path",
              "required": true,
              "type": "string",
              "description": "ID of the Office 365 Group",
              "x-ms-summary": "Group Id",
              "x-ms-visibility": "important"
            },
            {
              "name": "Content-Type",
              "in": "header",
              "required": false,
              "type": "string",
              "default": "application/json",
              "x-ms-visibility": "internal"
            },
            {
              "name": "body",
              "in": "body",
              "schema": {
                "type": "object",
                "properties": {
                  "guestSettings": {
                    "type": "object",
                    "properties": {
                      "allowCreateUpdateChannels": {
                        "type": "boolean",
                        "description": "Allow create and update channels",
                        "x-ms-summary": "allowCreateUpdateChannels",
                        "title": "Allow create and update channels",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowDeleteChannels": {
                        "type": "boolean",
                        "description": "Allow delete channels",
                        "x-ms-summary": "allowDeleteChannels",
                        "title": "Allow delete channels",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      }
                    },
                    "description": "Guests",
                    "x-ms-summary": "Guests:"
                  },
                  "memberSettings": {
                    "type": "object",
                    "properties": {
                      "allowCreateUpdateChannels": {
                        "type": "boolean",
                        "description": "Allow create and update channels",
                        "x-ms-summary": "allowCreateUpdateChannels",
                        "title": "Allow create update channels",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowDeleteChannels": {
                        "type": "boolean",
                        "description": "Allow delete channels",
                        "x-ms-summary": "allowDeleteChannels",
                        "title": "Allow delete channels",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowAddRemoveApps": {
                        "type": "boolean",
                        "description": "Allow add and remove apps",
                        "x-ms-summary": "allowAddRemoveApps",
                        "title": "Allow add and remove apps",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowCreateUpdateRemoveTabs": {
                        "type": "boolean",
                        "description": "Allow create, add and remove apps",
                        "x-ms-summary": "allowCreateUpdateRemoveTabs",
                        "title": "Allow create, add and remove apps",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowCreateUpdateRemoveConnectors": {
                        "type": "boolean",
                        "description": "Allow create, add and update connectors",
                        "x-ms-summary": "allowCreateUpdateRemoveConnectors",
                        "title": "Allow create, add and update connectors",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      }
                    },
                    "description": "Members",
                    "x-ms-summary": "Members:"
                  },
                  "messagingSettings": {
                    "type": "object",
                    "properties": {
                      "allowUserEditMessages": {
                        "type": "boolean",
                        "description": "Allow users to edit messages",
                        "x-ms-summary": "allowUserEditMessages",
                        "title": "Allow users to edit messages",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowUserDeleteMessages": {
                        "type": "boolean",
                        "description": "Allow users to delete messages",
                        "x-ms-summary": "allowUserDeleteMessages",
                        "title": "Allow users to delete messages",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowOwnerDeleteMessages": {
                        "type": "boolean",
                        "description": "Allow owners to delete messages",
                        "x-ms-summary": "allowOwnerDeleteMessages",
                        "title": "Allow owners to delete messages",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowTeamMentions": {
                        "type": "boolean",
                        "description": "Allow team mentions",
                        "x-ms-summary": "allowTeamMentions",
                        "title": "Allow team mentions",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowChannelMentions": {
                        "type": "boolean",
                        "description": "Allow channel mentions",
                        "x-ms-summary": "allowChannelMentions",
                        "title": "Allow channel mentions",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      }
                    },
                    "description": "Settings",
                    "x-ms-summary": "Settings:"
                  },
                  "funSettings": {
                    "type": "object",
                    "properties": {
                      "allowGiphy": {
                        "type": "boolean",
                        "description": "Allow Giphy",
                        "x-ms-summary": "allowGiphy",
                        "title": "Allow Giphy",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "giphyContentRating": {
                        "type": "string",
                        "description": "Giphy Content Rating",
                        "x-ms-summary": "giphyContentRating",
                        "title": "Giphy Content Rating",
                        "x-ms-visibility": "advanced",
                        "default": "strict"
                      },
                      "allowStickersAndMemes": {
                        "type": "boolean",
                        "description": "Allow stickers and memes",
                        "x-ms-summary": "allowStickersAndMemes",
                        "title": "Allow stickers and memes",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      },
                      "allowCustomMemes": {
                        "type": "boolean",
                        "description": "Allow custom memes",
                        "x-ms-summary": "allowCustomMemes",
                        "title": "Allow custom memes",
                        "x-ms-visibility": "advanced",
                        "enum": [
                          "true",
                          "false"
                        ],
                        "default": "true"
                      }
                    },
                    "description": "Fun",
                    "x-ms-summary": "Fun:"
                  }
                }
              }
            }
          ]
        }
      }
    },
    "definitions": {},
    "parameters": {},
    "responses": {},
    "securityDefinitions": {
      "oauth2_auth": {
        "type": "oauth2",
        "flow": "accessCode",
        "authorizationUrl": "https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/authorize",
        "tokenUrl": "https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/token",
        "scopes": {
          "Group.ReadWrite.All": "Group.ReadWrite.All"
        }
      }
    },
    "security": [
      {
        "oauth2_auth": [
          "Group.ReadWrite.All"
        ]
      }
    ],
    "tags": []
  }

Next, several steps need to be taken, in order the connector to be ready to use [2].

  1. Register an App in the Azure Portal
    • Register a new Azure AD App in Azure Active Directory
    • Add Microsoft Graph permissions for delegated „Read and write all groups“ (Group.ReadWrite.All)
    • Save the application id (Client Id) – it will be needed in the steps that follow.
    • Generate and save a key (Client Secret) – it will be needed in the steps that follow.
  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 (see Figure 1, Figure 2)

     

    Figure 1: PowerApps – Navigate to Custom connectors
    Figure 2: PowerApps – Import an OpenAPI file
    Figure 3: PowerApps – Custom Connector Settings

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    • Enter a title for the connector e.g. „Microsoft Teams Extension CC“ and choose the json file presented before
    • In General – verify the following settings:
      Scheme:  HTTPS; Host: „graph.microsoft.com“; Base URL „/“ (see Figure 3).
    • In Security – choose as authentication type „OAuth 2.0“ (see Figure 4)
      • Select „Generic Oauth 2“ as Identity Provider
      • Client Id – paste the one that you have saved from step 1
      • Client Secret – paste the one that you have saved from step 1
      • Authorization URL – Paste „https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/authorize“
      • Token URL – Paste „https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/token“
      • Refresh URL – Paste „https://login.microsoftonline.com/yourtenant.onmicrosoft.com/oauth2/v2.0/token“
      • Scope – Paste „Group.ReadWrite.All“
      • Redirect URL – it will be automatically generated after the custom connector is saved
      • 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
Figure 4: PowerApps – Security Settings

 

Your Custom Connector is now ready to be used!

It will be shown in Microsoft Flow with all of its options as depicted by Figure 5.

 

Figure 5: The Custom Connector in Microsoft Flow

Use your Custom Connector in Microsoft Flow

Before using your Custom Connector, you should add the following Action – “Azure AD – Create Group”. The ID of this group will be used after that as input for your Custom Connector. However, in order to use the Azure AD connector, the account needs to have the following administrator permissions [3]:

  • Group.ReadWrite.All
  • User.ReadWrite.All
  • Directory.ReadWrite.All

What is left unclear in the documentation by Microsoft is where and how actually to give those permissions. Many have been asking these questions in the forums on the topic.

Well, we at Veroo Consulting have found out that the account, used for the Flow connection, should be granted the role of an Application Administrator (see Figure 6). Further information about the available roles in Azure Active Directory can be found in the documentation, provided by Microsoft  [4].

Figure 6: Microsoft Azure Active Directory – Roles and administrators

Alternatively, if you prefer not to give all the rights of an Application Administrator to the account, a custom role can be created instead in Azure that has only the needed permissions listed above. Further information about how to create a custom role in Azure can be found in the documentation from Microsoft [5].

Another thing to consider is, if there is a restriction that was previously created so that only users that are part of an Office 365 Security Group can create groups [6]. If that is the case, the user account, listed in the corresponding flow connection, should be added to this Security Group.

When all of the needed permissions are granted, the connection between the two Actions can be made (see Figure 7).

Figure 7: Using the Custom Connector in Microsoft Flow

 

Congratulations, now you are a step forward towards an automated and productive working environment 🙂

 

References

[1] Microsoft, „Microsoft Flow – Work less, do more,“ Microsoft, 2017. [Online]. Available: https://flow.microsoft.com/en-us/. [Accessed 29 11 2018].
[2] C. Glessner, „Create a Microsoft Team with Flow (Custom Connector),“ leitwolf.io, 08 03 2018. [Online]. Available: https://blog.leitwolf.io/create-a-microsoft-team-with-flow-custom-connector/. [Accessed 29 11 2018].
[3] Microsoft, „Connector Reference – Azure AD,“ Microsoft, [Online]. Available: https://docs.microsoft.com/en-us/connectors/azuread/#/providers/microsoft.powerapps/apis/shared_azuread/apioperations/creategroup. [Accessed 29 11 2018].
[4] Microsoft, „Microsoft Azure – Administrator role permissions in Azure Active Directory,“ 26 10 2018. [Online]. Available: https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles. [Accessed 29 11 2018].
[5] Microsoft, „Azure Role-based access control – Custom roles in Azure,“ Microsoft, 24 09 2018. [Online]. Available: https://docs.microsoft.com/en-us/azure/role-based-access-control/custom-roles. [Accessed 29 11 2018].
[6] Microsoft, „Office 365 – Manage who can create Office 365 Groups,“ 26 10 2018. [Online]. Available: https://docs.microsoft.com/en-us/office365/admin/create-groups/manage-creation-of-groups?redirectSourcePath=%252fen-us%252farticle%252fManage-Office-365-Group-creation-4c46c8cb-17d0-44b5-9776-005fced8e618&view=o365-worldwide. [Accessed 29 11 2018].

 

Tags

Newsletter

Sie wollen Up-to-Date bleiben?
hier abonnieren
How to Create a Team by using Microsoft Flow

One thought on “How to Create a Team by using Microsoft Flow

  • Dezember 6, 2018 um 10:29 am
    Permalink

    Creat article, Sonia. Thank you 🙂

Kommentare sind geschlossen.

GDPR Cookie Consent mit Real Cookie Banner