Azure Logic Apps¶
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.
- The main flow triggers when a new row is added into the Teams Requests table in Dataverse.
- 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.
- 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.
- 7 variables are initialized that are used later on in the flow
Channels
: contains the array representation of the channels that need to be created.DriveExistsCode
: stores the response of an HTTP request to check whether the SharePoint library has already been created for the team.SiteExistsCode
: stores the response of an HTTP request to check whether the SharePoint site for the team has already been created.LibraryColumns
: array representation of the columns that need to be created in the library.ListColumns
: array representation of the columns that need to be created in the list.Members
: contains members to be added to the TeamsOwners
: contains owners to be added to the Teams- 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.
- The team is created in the Create Team scope, which is expanded below
- The related team channel rows are listed
- The channels are added into the
Channels
variable - A child logic app is called with the team information and channels as input
- The Team ID is extracted from the child logic app's response
- We wait until we get confirmation that the SharePoint site for the team has been created
- We wait until we get confirmation that the default files library for the team has been created
- The folder path for the default files library is composed based on the output of the previous actions
- The lists and libraries defined in the request are created in the Create Lists and Libraries scope.
- The related list rows are listed
- For each related list
- The related columns are listed
- The column definition is added to the Columns variable
- A child logic app is called to create the list with its columns
- The related library rows are listed
- For each related library
- The related columns are listed
- The columns definition is added to the Columns variable
- A child logic app is called to create the library with its columns
- The task list is added to the team if the owner has indicated they want this in their team
- The welcome package is added to the team if the owner has indicated they want this in their team
- The related rows of the intersection table
pg_teamsuser_teamsrequest_members
get listed - For each member the
members
variable gets appended to then reflect the UPN - The related rows of the intersection table
pg_teamsuser_teamsrequest_owners
get listed - For each member the
owners
variable gets appended to then reflect the UPN - 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.
- The Logic Apps flow is triggered from an HTTP request, for example when being called as a child logic app
- 6 variables are initialized
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.DisplayName
: the name that users should see in the Microsoft Teams app.Description
: the description of the team.TeamCreationRequestCode
: variable to store the response the HTTP request to create the team to check whether the request was accepted.TeamCreationStatus
: variable to store the response of an HTTP request to check whether the creation of the team has completed.NewTeamId
: the ID of the new team.- The information of the Team owner is requested to Azure AD using an HTTP request
- The owner information is parsed so its properties can be used later in the Logic Apps flow
- The group for the team is created as a private group
- The group creation request body is parsed to use the properties later in the Logic Apps flow
- The group ID is stored in the
NewTeamId
variable - The following actions are done in a loop because this does not always succeed on the first try
- A request is sent to "teamify" the created group
- The status code is saved in the
TeamCreationStatus
variable - If team creation has not been accepted, there is a delay of 10 seconds
- The loop will stop when the HTTP request to teamify the group has been accepted
- The headers of the team creation request are parsed to extract the information for use later in the Logic Apps flow
- The following actions are done in a loop because teamification of the group can take some time
- An HTTP request is sent to determine the creation status of the team for the group
- The response is parsed
TeamsCreationStatus
is updated with the status of the HTTP request- If team creation has not succeeded, a 10 second delay is added
- The loop will stop when team creation has succeeded
- The channels that have been created in the team are listed
- Channel information is parsed so it can be used in the following actions
- For each channel
- The wiki tab is identified based on its name
- The wiki tab info is parsed
- The wiki tab is deleted from the channel
- A response is provided to the caller of the logic app with the team id.
3. Add people¶
- The logic app is triggered from a HTTP request as a child flow
- An array variable
People
is initialized - The members get splitted by an
;
- the
People
variable gets appended with the body that we need in the HTTP request to add members - The owners get splitted by an
;
- the
People
variable gets appended with the body that we need in the HTTP request to add owners - HTTP request adds both members get added in a single call
- for each guest, the UPN gets created
- TRY scope: we check if this user already exists in Azure Active Directory
- CATCH scope: we invite the user to the tenat and wait until they accepted the invitation and update the user information for
firstName
,lastName
andOrganization
- We add the user to the group
- 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:
- The logic app is triggered from a HTTP request, for example as a child logic app.
- A
ListColumns
variable is initialized to store the column definition - A
ResourceType
variable is initialized to store if it is a list or a library - For each of the columns that are specified in the trigger
- Depending on the type of column, append the column definition to the
ListColumns
variable - Switch cases for the columnm types
- Switch cases for the resource types
- Create the list/library using a request using the resource type
- 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.
- The Logic Apps flow is triggered from a HTTP request, for example as a child Logic Apps flow
- A
listColumns
variable is initialized with a fixed definition of the columns needed for the task list - The Create List Logic Apps flow is called with the task list fixed column definition to create the task list
- 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
- The Logic Apps is triggered from a HTTP request, for example as a child logic app
- The request body is parsed to extract the required information
- 2 variables are initialized:
TeamId
: the ID of the team to which the welcome package should be addedOwner
: the owner of the team (UPN)- A HTTP request lists the channels in the team
- The channel info is parsed
- The General channel is always the first channel returned when the channels are listed, this is extracted from the channel info
- An HTTP request is sent to add the training material URLas a website tab in the new team's general channel
- 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.
- The Logic Apps is triggered from a HTTP request, for example as a child logic app
- An HTTP request lists the channels in the team
- An HTTP request triggers the creation of the Notebook in the site that backs the Team.
- An HTTP request gets the notebook information
- An HTTP request creates a section in the notebook
- An HTTP request creates a page in the notebook
- A variable is initialized for the
Notebook URL
- An HTTP request adds the Notebook to the Channel General
- Respond to the request caller