-
Notifications
You must be signed in to change notification settings - Fork 7
2. Deployment
Pre-requisites
Deployment machine
- The following PowerShell modules needs to be installed prior to the execution of the PShell script:
- Azure Az - https://docs.microsoft.com/en-us/powershell/azure/install-az-ps - Solution built and tested with v7.2.3
- Microsoft Graph - https://docs.microsoft.com/en-us/powershell/microsoftgraph/overview?view=graph-powershell-beta
- SharePoint PNP - https://pnp.github.io/powershell/articles/installation.html - Required to create the SharePoint lists
Environment
- Azure Subscription and account with contributor role (to deploy resources)
- M365 Subscription (to create the SharePoint site)
Permissions
- Azure AD admin role to create the Service Account, assign roles and register a new application
- Azure account with contributor role (to deploy resources)
- Permissions to create a new SharePoint site
Note: in this deployment, we assume that the same user has the appropriate permissions to deploy the resources on Azure, Power Platform and Azure AD. This is however not mandatory and the deployment can be split across these different roles and responsabilities within the organization.
Licenses/Subscriptions
- Azure Subscription
- M365 Subscription (to create the SharePoint site)
- Azure AD Premium P1 license to enable Azure AD Conditional Access Although this is optional it is strongly recommended to protect the service account
- Power App license to deploy the application and Power Automate flows
- Power App Premium license for the Power Automate flows
Use the steps below to install PowerShell 7.x on the machine used for the deployment of the app:
- Go to https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2#msi
- Select the correct platform (x64 or x86)
- Once the file has been downloaded install the MSI
Use the steps below to install the Azure Az PowerShell module:
- In your startmenu search for PowerShell 7, once found click on it to open PowerShell 7
- Run the following cmdlet to install the latest version of the Azure Az PowerShell module:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
This will install the Azure Az PowerShell module only for the user which is currently logged in.
Use the steps below to install the Microsoft Graph PowerShell module:
- If you closed the previous PowerShell window, search in the startmenu for PowerShell 7, once found click on it to open PowerShell 7
- Run the following cmdlet to install the latest version of the Microsoft Graph PowerShell module:
Install-Module Microsoft.Graph -Scope CurrentUser -Repository PSGallery -Force
This will install the Microsoft Graph PowerShell module only for the user which is currently logged in.
Use the steps below to install the Microsoft Graph PowerShell module:
- If you closed the previous PowerShell window, search in the startmenu for PowerShell 7, once found click on it to open PowerShell 7
- Run the following cmdlet to install the latest version of the PnP PowerShell module:
Install-Module -Name "PnP.PowerShell" -Scope CurrentUser -Repository PSGallery -Force
This will install the PnP PowerShell module only for the user which is currently logged in.
Account required:
- service account or account with the required roles descriped in the role required section
Role required:
- Azure AD admin
- Go to the Azure AD portal to manage users
- Add a new user (e.g. "Service Account Teams admin") and save the password
Note: you'll need to reset this password the first time you use this account - Please connect to https://portal.azure.com with the user credentials and provide a new complex password - Store this password in a secured location
- Under assigned roles assign the following roles :
- Directory readers - to read the user profiles
- Teams communications administration
- Skype for Business Administrator
Account required:
- service account or account with the required roles descriped in the roles required section
Roles required:
- Azure contributor
- Azure AD app registration autorized for members of the tenant (or specific Azure AD role assigned for app registration)
During the creation of the resources the following permissions will be automatically configured:
- Service account: get/list secrets
- Account which is used to execute this script: get/list secrets
- Azure Function App will receive the following Graph Permissions
- Sites.Selected
- Group.Read.All
To execute this deployment step, you need to download the content of this repository on your local environment and run the PowerShell script under .\Deployment\deploy.ps1
- Download the content of this repository
- Execute the script deploy.ps1 as follow:
.\deploy.ps1 -displayName <Name of Azure AD registered app> -rgName <Name of the resource group> -resourcePrefix <prefix for Azure resources -location <Azure region> -serviceAccountUPN <UPN of the service account created in step 1> -serviceAccountSecret <Password of the service account created in step 1>` (optional) -subscriptionID <Azure subscription id>
Example
.\deploy.ps1 -displayName "AA and CQ management" -rgName "aacqmgmtrg" -resourcePrefix "AACQmgmt" -location "West Europe" -serviceAccountUPN aacqmgmt-service@contoso.com -serviceAccountSecret Password01
The deployment can take several minutes, including the warm-up time of the Azure Functions - At the end of the deployment, check the outputs that will be required to configure the deployment of the Power App and Azure AD Conditional Access
A successful deployment should look like that (by default, the script runs 3 times)
Deployment script completed.
Here is the information you ll need to deploy and configure the Power Application
FunctionApp : 'https://AACQmgmt-nnjqs.azurewebsites.net'
FunctionKey : 'pujmFZfGxwqGXXXdddxLs2xXXXg2cMLhAUUE2Q=='
Tenant : 'contoso.onmicrosoft.com'
ApplcationId : 'bad28fb5-XXXX-XXXX-XXXX-665886c2cbad'
KeyVaultName : 'az-vault-6cdgs'
AzFunctionIPs : '104.45.68.78,104.45.69.84,104.45.69.210,104.45.69.232,104.45.66.240,104.45.70.42,20.50.2.80'
As we can imagine that organizations want to control when updates are installed we have listed steps below how to migrate the Azure Function App from running as a package to a solution which does not pull it's package from this repository.
- Go to the Azure function
- From the left menu select Advanced Tools in the Development Tools section
- In the main pane select go
- From the top menu select **Debug Console **and select PowerShell
- Wait till everything is loaded
- In the "explorer" view select site
- Click on the 3 dots next to wwwroot and select the option Download to download a zip with all the content
- Wait for the download the be completed
- Go back to the Azure Function page and selection Configuration in the Settings section
- Search for the entry WEBSITE_RUN_FROM_PACKAGE
- Delete the entry completely
- After a few seconds/minutes go to Functions in the Functions section and you will see everything has been removed
- Go back to the Debug Console window
- Inside the **wwwroot **put the content from the zip into the directory
- Go back to the Azure Function page and validate the functions are visible again
This steps assumes that you already created the SharePoint Online site which will be used to store both the audio prompts and the SharePoint Online lists.
Run the following cmdlet's to connect to SharePoint Online and import the lists from the XML file.
Connect-PnPOnline -Url https://m365x18873442.sharepoint.com/sites/Teamsvoicemanagement -Interactive
Invoke-PnPSiteTemplate -Path c:\temp\Lists.xml
Once executed go to the SharePoint Online site and validate the SharePoint Lists are created.
Deploying the Power App and Flows is being performed by importing a solution in the Power Apps environment. It is recommended to import the solution in a separate Power App environment if possible.
To import the solution perform the following steps:
- Go to https://make.powerapps.com
- In the left menu select Solutions
- From the top menu select Import
- In the new pane validate the correct environment is selected and press browse
- Select the ZIP file named AutoAttendantandCallQueueManagement_1_X_X_X.zip from the Packages/PowerApps folder
- Press the Next button to continue
- Review the details of the package and press Next
- Update the CON - SPO Auto attendant And CallQueue connection by selecting the dropdown menu next to the connection and select the New Connection option, a new tab will be opened (don't close the previous tab)
- On the new tab select Connect directly (cloud-services) and press Create
- An authentication prompt will be shown, make sure you select the service account created earlier, if not listed select Use another account and specify the credentials from the service account
- Close the tab and go back to the original tab and press the **Refresh **button
- Select the connection created from the drop down list
- Update the CON- O365 User AutoAttendant and connection by selecting the dropdown menu next to the connection and select the New Connection option, a new tab will be opened (don't close the previous tab) 14.On the new tab press the **Create **button
- An authentication prompt will be shown, make sure you select the service account created earlier, if not listed select Use another account and specify the credentials from the service account
- Close the tab and go back to the original tab and press the **Refresh **button
- Select the connection created from the drop down list
- Update the CON- Vault connection by selecting the dropdown menu next to the connection and select the New Connection option, a new tab will be opened (don't close the previous tab) 19.On the new tab press the **Create **button
- An authentication prompt will be shown, make sure you select the service account created earlier, if not listed select Use another account and specify the credentials from the service account
- Close the tab and go back to the original tab and press the **Refresh **button
- Select the connection created from the drop down list
- Once all 3 connections have been updated press the Next button
- Populate the fields with the values provided as output from the Azure deployment script:
- VAR - FunctionKey: value of the host function key
- VAR - Tenant: tenantname, for example contoso.onmicrosoft.com
- VAR - application id: Application (Client) ID of the App registration in Azure AD
- VAR - FunctionApp: name of the function app
- VAR - TeamsvoicemanagementSPSite: SharePoint Site name
- Once all values are provided continue with importing the solution, this might take several minutes, while importing the following message will be show on the top of the page:
- Once imported you will see the TACO entry in the list of solutions:
- Click on the 3 dots and select Edit
- Find the TACO app (Teams AA CQ Orchestrator (TACO)
- Click on the 3 dots and select Edit
- In the left menu select data (database icon)
- Click on the 3 dots next to one of the SharePoint list and select Edit data
- Confirm the SharePoint site opens correctly
If the above steps doesn't result in the SharePoint site to open the data connections have not been updated correctly. In this situation there are 2 options:
- reimport the solution
- remove and recreate all SharePoint entries (WARNING: this might require you to update all SharePoint blocks in the workflows also)
Only perform these steps if the SharePoint connections are not updated correctly.
WARNING: this might require you to update all SharePoint blocks in the workflows also
- Remove all current SharePoint entries
- Click on Add data to readd the SharePoint entries
- Select advanced and select the variable VAR- SPO Site AutoAttendant ....
- Select:
- Auto Attendant management
- Auto Attendant - holidays
- Call Queue management
- Holidays
- User administration
- Voice management audit log
- Confirm all entries are added
- Click on the 3 dots next to one of the entries and select Edit data
- Confirm a new tab is opened with the SharePoint list
- (optionally) repeat this for the other items
- Update all workflows
You can enable Azure Conditional Access on the Service Account used by your Azure Function app and restrict the trusted IP's to the one used by Azure Function. Azure AD Conditional Access requires a Premium P1 license to be assigned - More info here on license requirements.
- Go to the Azure AD portal for Conditional Access management
- Select "Named location" and create a new IP range location
- Provide a name (e.g. "Azure Function app Teams admin") and mark the location as trusted location
- Enter all the IP addresses provided in the output of the deployment in step #2 (AzFunctionIPs) - Append a "/32" to each IP address
- Click on Create
- Go to Policies and then click on "Create new policy"
- Provide a name to your policy
- For the Assignments:
- Users or workload identities > Include "Select users and groups" > check "User and groups" > search for your Service Account > Select
- Cloud apps or actions > Include "All cloud apps"
- Conditions > Locations > Exclude "Selected locations" > "Azure Function app Teams admin" (created earlier)
- For the Access Controls:
- Grant > Block access
- Enable policy
- Save to confirm and apply the changes
Note: please go back to your Power App and check that the application still responds - You can also try to use the Service Principal credential from your local desktop and verity you can't login anymore.
You now have the application deployed in Teams and you need to provide access to "delegated admins" in your organization. To achieve that, we'll use the Office 365 group of the team where the Power Apps has been deployed.
- All "delegated admins" needs to be invited in the team to access the Power App
- The 1st time your users will access the Power App in Teams, they will need to consent to use the 2 connectors (SharePoint and Office365)
Make sure you also assigned permissions to the SharePoint site which contains the SharePoint lists, failing to do this will result in an empty Power App even if the users have the correct permissions.