Skip to content

Azure Logic Apps

header image

We created 7 Azure Logic Apps to handle the provisioning of the Teams:

Our flows pick up the values logged in the Dataverse tables to provision what the user requested:

1. Main flow

The main flow takes care of the logic of the flows: executing the different steps in the right order and providing the right input. An overview of the Logic App is added below.

Screenshot of the main flow

  1. The main flow triggers when a new row is added into the Teams Requests table in Dataverse.
  2. The internal name of the to be created team is generated using the name provided by the team owner and a generated guid. This ensures that all team names are unique.
  3. The technical name is updated in the Teams Request row so that admins can easily find out which requests are linked to which Microsoft Teams teams.
  4. 7 variables are initialized that are used later on in the flow
  5. Channels: contains the array representation of the channels that need to be created.
  6. DriveExistsCode: stores the response of an HTTP request to check whether the SharePoint library has already been created for the team.
  7. SiteExistsCode: stores the response of an HTTP request to check whether the SharePoint site for the team has already been created.
  8. LibraryColumns: array representation of the columns that need to be created in the library.
  9. ListColumns: array representation of the columns that need to be created in the list.
  10. Members: contains members to be added to the Teams
  11. Owners: contains owners to be added to the Teams
  12. A 1 minute delay is added to ensure that the channels and other related table rows are linked to the Teams request row in Dataverse, since these cannot be linked upon creation of the Teams request row.
  13. The team is created in the Create Team scope, which is expanded below
  14. The related team channel rows are listed
  15. The channels are added into the Channels variable
  16. A child logic app is called with the team information and channels as input
  17. The Team ID is extracted from the child logic app's response
  18. We wait until we get confirmation that the SharePoint site for the team has been created
  19. We wait until we get confirmation that the default files library for the team has been created
  20. The folder path for the default files library is composed based on the output of the previous actions

Scope Create Team

  1. The lists and libraries defined in the request are created in the Create Lists and Libraries scope.
  2. The related list rows are listed
  3. For each related list
    1. The related columns are listed
    2. The column definition is added to the Columns variable
    3. A child logic app is called to create the list with its columns
  4. The related library rows are listed
  5. For each related library
    1. The related columns are listed
    2. The columns definition is added to the Columns variable
    3. A child logic app is called to create the library with its columns

Scope Create Lists and Libraries

  1. The task list is added to the team if the owner has indicated they want this in their team
  2. The welcome package is added to the team if the owner has indicated they want this in their team

Scope Add People Scope Add People Scope Add People

  1. The related rows of the intersection table pg_teamsuser_teamsrequest_members get listed
  2. For each member the members variable gets appended to then reflect the UPN
  3. The related rows of the intersection table pg_teamsuser_teamsrequest_owners get listed
  4. For each member the owners variable gets appended to then reflect the UPN
  5. In case members or owners are not empty, the ProvisionGenie-AddPeople flow gets called

2. Create team

In the Create team flow, the requested team is created with the specified channels. Additionally, the wiki is removed from each of the channels. An overview of the flow is added below.

Create Team logic app overview

  1. The Logic Apps flow is triggered from an HTTP request, for example when being called as a child logic app
  2. 6 variables are initialized
  3. TechnicalName: the internal name that the team should be initialized with, this is used in the email address and SharePoint site url for the team.
  4. DisplayName: the name that users should see in the Microsoft Teams app.
  5. Description: the description of the team.
  6. TeamCreationRequestCode: variable to store the response the HTTP request to create the team to check whether the request was accepted.
  7. TeamCreationStatus: variable to store the response of an HTTP request to check whether the creation of the team has completed.
  8. NewTeamId: the ID of the new team.
  9. The information of the Team owner is requested to Azure AD using an HTTP request
  10. The owner information is parsed so its properties can be used later in the Logic Apps flow
  11. The group for the team is created as a private group
  12. The group creation request body is parsed to use the properties later in the Logic Apps flow
  13. The group ID is stored in the NewTeamId variable
  14. The following actions are done in a loop because this does not always succeed on the first try
  15. A request is sent to "teamify" the created group
  16. The status code is saved in the TeamCreationStatus variable
  17. If team creation has not been accepted, there is a delay of 10 seconds
  18. The loop will stop when the HTTP request to teamify the group has been accepted

Teamify loop

  1. The headers of the team creation request are parsed to extract the information for use later in the Logic Apps flow
  2. The following actions are done in a loop because teamification of the group can take some time
    1. An HTTP request is sent to determine the creation status of the team for the group
    2. The response is parsed
    3. TeamsCreationStatus is updated with the status of the HTTP request
    4. If team creation has not succeeded, a 10 second delay is added
    5. The loop will stop when team creation has succeeded

Teamify completed loop

  1. The channels that have been created in the team are listed
  2. Channel information is parsed so it can be used in the following actions
  3. For each channel
    1. The wiki tab is identified based on its name
    2. The wiki tab info is parsed
    3. The wiki tab is deleted from the channel

Wiki deletion actions

  1. A response is provided to the caller of the logic app with the team id.

3. Add people

AddPeople Logic App

  1. The logic app is triggered from a HTTP request as a child flow
  2. An array variable People is initialized
  3. The members get splitted by an ;
  4. the People variable gets appended with the body that we need in the HTTP request to add members
  5. The owners get splitted by an ;
  6. the People variable gets appended with the body that we need in the HTTP request to add owners
  7. HTTP request adds both members get added in a single call
  8. for each guest, the UPN gets created
  9. TRY scope: we check if this user already exists in Azure Active Directory
  10. CATCH scope: we invite the user to the tenat and wait until they accepted the invitation and update the user information for firstName, lastName and Organization
  11. We add the user to the group
  12. Respond to the request caller

4. Create List/Library

As the logic for creating a list and creating a library is very similar, we do this in one flow:

Create List/Library logic app overview

  1. The logic app is triggered from a HTTP request, for example as a child logic app.
  2. A ListColumns variable is initialized to store the column definition
  3. A ResourceType variable is initialized to store if it is a list or a library
  4. For each of the columns that are specified in the trigger
  5. Depending on the type of column, append the column definition to the ListColumns variable
  6. Switch cases for the columnm types
  7. Switch cases for the resource types
  8. Create the list/library using a request using the resource type
  9. Respond to the request caller

5. Create Task List

The Create Task list logic app uses the CreateLibraryList logic app to create a task list using a fixed definition of columns.

Create Task List overview

  1. The Logic Apps flow is triggered from a HTTP request, for example as a child Logic Apps flow
  2. A listColumns variable is initialized with a fixed definition of the columns needed for the task list
  3. The Create List Logic Apps flow is called with the task list fixed column definition to create the task list
  4. Respond to the request caller

6. Welcome Package

The welcome package adds a url with training material to the General channel of the new team

Welcome Package Overview

  1. The Logic Apps is triggered from a HTTP request, for example as a child logic app
  2. The request body is parsed to extract the required information
  3. 2 variables are initialized:
  4. TeamId: the ID of the team to which the welcome package should be added
  5. Owner: the owner of the team (UPN)
  6. A HTTP request lists the channels in the team
  7. The channel info is parsed
  8. The General channel is always the first channel returned when the channels are listed, this is extracted from the channel info
  9. An HTTP request is sent to add the training material URLas a website tab in the new team's general channel
  10. Respond to the request caller

7. Add Notebook

This flow adds the notebook of the SharePoint sites, that backs the team, to the channel General and creates the first section and the first page.

Add Notebook Overview

  1. The Logic Apps is triggered from a HTTP request, for example as a child logic app
  2. An HTTP request lists the channels in the team
  3. An HTTP request triggers the creation of the Notebook in the site that backs the Team.
  4. An HTTP request gets the notebook information
  5. An HTTP request creates a section in the notebook
  6. An HTTP request creates a page in the notebook
  7. A variable is initialized for the Notebook URL
  8. An HTTP request adds the Notebook to the Channel General
  9. Respond to the request caller