-
Notifications
You must be signed in to change notification settings - Fork 3
Deployment Guide
To begin, you will need:
- An Azure subscription where you can create the following kinds of resources:
- App Service
- App Service Plan
- Application Insights
- Function App
- Key Vault
- Search Service
- SQL Database
- SQL Service
- Storage Account
- Permissions to create and configure AAD App Registrations
- The GovAddressBook repository downloaded: https://github.com/engagesquared/GovAddressBook
- Global Administrator access to a M365 tenant with Teams enabled - this will be the account used to deploy the teams app
- A shell terminal - Powershell or Azure Cloud Shell are recommended. Your terminal will need to have the following installed and configured:
- npm - https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
- gulp - https://gulpjs.com/docs/en/getting-started/quick-start/
- Azure CLI - https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-powershell
- Terraform CLI - https://www.terraform.io/downloads.html Note: Terraform must be added to your PATH environment variable
| Topic | Description |
|---|---|
| Synopsis | The deployment process of the app involves 3 main procedures, creating the Azure resources within the resource group, setting up the app registration and deploying the app manifest of the web-app-teams, web-app-external and func-app-refresh to the app services and function app within the resource group |
| Estimated Time to Complete | 2 hours |
- Open the Azure Portal and create a new Resource Group
- Name the Resource Group
{{company-name}}-{{environment}}-directory-rg. For example:contosouav-production-directory-rgNote: Azure resources and their URL endpoints must be globally unique. You may run into issues with deployment if there is a naming conflict with another instance. - Set the region, then submit to create your new Resource Group
-
Login to the Azure Portal
-
Open Active Directory
-
Note down the Tenant ID - it will be used in several steps throughout this guide.

-
Open the Azure Portal
Note: If you are deploying GovAddressBook to an M365 tenant that is distinct from Azure tenant, you must log into that Azure account.
-
Navigate to Active Directory > App Registrations
-
Create a new App Registration with name govaddressbook-app. Leave the other fields as default
Keep this tab open as you will need several values from your App Registration when configuring your deployment
- With the repository downloaded, open the / azure-resources folder in file explorer
- Open the main.tf file in a text editor, such as VSCode.
- Use the find tool to search for
{{company-name}}and replace it with your organisation's name in lowercase, with spaces removed. For example:contosouav - Use the find tool to search for
{{environment}}and replace it with your target environment. For example:uat - Use the find tool to search for
{{db-password}}and replace it with a secure password. - Use the find tool to search for
{{db-user}}and replace it with "sqlAdmin" - Use the find tool to search for
{{reg-app-tenant-id}}and replace it with the Tenant ID found in your App Registration - Use the find tool to search for
{{reg-app-id}}and replace it with your App Registration's ID - Use the find tool to search for
{{self-external-api-key}}and replace it with a Unique GUID - Save and close the file
-
Open your terminal program, such as PowerShell
-
Open the azure-resources folder in the code repo in the terminal
-
Run the following command to login to your Azure tenant, replacing
<tenant-id>with your AAD tenant ID captured in the previous step.az login --tenant <tenant-id>You will be prompted to enter login to your Azure account.
Once you have logged in, your terminal will return a list of all the Azure Subscriptions you have access to with this account. The Subscription that has
IsDefault: truewill be our target subscription. You can change your active subscription if needed. -
Run the below command to initialize the working directory containing Terraform configuration files:
terraform init -
Run the below command to check whether the execution plan matches your expectations without making any changes to real resources or to the state:
terraform planIf applied correctly, you should be creating 19 resources in your target Resource Group
-
Run below command to deploy the resources to your Resource Group:
terraform applyIt should take approximately 10-15 minutes to finish creating your resources.
-
Open the Azure portal and navigate to key vault within the resource group you created
-
Go to Certificates and selected the Certificate that has been created.

-
Select the Current Version of the Certificate, then Download the .CER file of certificate.

Your browser may give a warning when trying to download this file. In some browsers, like Edge, you must right-click the download in your browser and click Keep.
-
Navigate to the Authentication page in your new App Registration and select Add a platform.
-
Select Web under Web Applications

-
Add in the redirect URI as the URL of the Teams app service from the resource group you created earlier. For example:
https://contosouav-uat-directory-teams.azurewebsites.net.You can retrieve this from the Overview page of the app service

-
Leave the Front-Channel Logout URL as blank.
Enable the Access tokens and ID tokens checkboxes then press configure.

-
Navigate to the expose an API page
Click the Set link to set your Application ID URI

A dialog will appear with an App ID URL already set. It will look something like
api://{GUID}for example:
api://a5f925fd-c103-464d-8cd4-8dc5539c52d6 -
Insert the URL of the teams app service (without
https://) afterapi://. Do not remove the existing GUID valueE.g.
api://contosouav-uat-directory-teams.azurewebsites.net/{GUID}
-
Save the App ID URI to close the dialog
-
Click the Add a scope button
-
Add a scope with the following details:
- Scope name = access_as_user
- Who can consent? = Admins and users
- Admin consent display name = Access as user
- Admin consent description = Allows the app to read user-profiles and send Teams Activity Feed notifications
- State = enabled
-
Click the Add scope button to save your changes
-
Click the Add a client application button
-
Add the following Client ID and enable the checkbox next to the authorized scope
1fec8e78-bce4-4aaf-ab1b-5451cc387264 -
Click Add application button to save your changes
-
Repeat Steps 14 – 16 with the following Client ID:
5e3ce6c0-2b1f-4285-8d4b-75ee78787346

- Navigate to the API permissions page
- Click the Add a permission button and then select Microsoft Graph as the type of API
- Select Delegated permissions and enable the following permissions:
- Directory.Read.All
- User.Read (Should already be enabled)
- User.Read.All
- Select Application permissions to change the type of permissions, the enable the following:
- MailboxSettings.Read
- TeamsActivity.Send
- User.Read.All
- Select the Add permissions button to save your changes.
- Select the Grant admin consent button. The Configured permissions table should look like this:

- Navigate to the Certificates & secrets page
- Select the Upload certificate button. Upload .CER certificate file you downloaded from key-vault within the resource group you created

-
Open the db-scripts folder from the code repo in file explorer
-
Open dbTables.sql in a text editor and copy the contents of the script file.
-
Open the SQL Database from the Resource Group and navigate to the Query editor page
-
Login to the database with sqlAdmin as the username, and the password you set in the main.tf file
If you are asked for a certificate, click OK to give it the default certificate.

-
You will receive a login error because your IP is restricted. Click the Whitelist link below the login form to whitelist your IP, then click OK to complete the login process.

-
Paste the contents of the script file you copied previously into the Query editor text field, then select the Run button.
If successful, an alert will appear at the bottom of the page, and if you expand the Tables icon, you will see several database tables have been generated.

If you aren't still logged into Azure with your terminal from the previous steps, make sure to run az login again to target your Azure subscription
-
Make a duplicate of the example.env file within the web-app-teams folder in the code repo, and rename it to .env. Use your text editor to update the following values:
-
Replace
{{company-name}}with the value set in the main.tf file. For example: contosouav -
Replace
{{environment}}with the value set in the main.tf file. For example: uat -
Replace
{{db-password}}with the password value set in the main.tf file -
Replace
{{azure-search-key}}with the Primary Key found in the Azure Search service in your Resource Group, on the Keys page
-
Replace
{{reg-app-id}}with the ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration

-
Replace
{{reg-app-tenant-id}}with the Tenant ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration
-
Replace
{{reg-app-cert-thumbprint}}with the Thumbprint of the Certificate you previously uploaded to the govaddressbook-app App Registration. You can obtain this value from the Certificates & secrets page of the App Registration
-
-
Save your changes to the file
-
cdinto the common folder and runnpm ito install common project dependencies -
cdinto the web-app-teams folder and run the following commands:-
npm ito install web-app-team dependencies -
npm i -g gulp-clito install gulp -
gulp buildto build the app -
gulp manifestto create the app package -
npm prune --productionto tidy unused files
-
-
Navigate to the web-app-teams > package folder in your terminal
-
Archive
dist,node_modules,package.jsonas a zip file, named web-app-teams.zip
- Make a duplicate of the example.env file within the web-app-external folder in the code repo, and rename it to .env. Update the following values:
- Replace
{{company-name}}with the value set in the main.tf file. For example:contosouav - Replace
{{environment}}with the value set in the main.tf file. For example:uat - Replace
{{db-password}}with the password value set in the main.tf file - Replace
{{azure-search-key}}with the Primary Key found in the Azure Search service in your Resource Group, on the Keys page - Replace
{{reg-app-id}}with the ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration - Replace
{{reg-app-cert-thumbprint}}with the Certificate Thumbprint from the Certificate uploaded to your App Registration. You can obtain this value by opening the govaddressbook-app App Registration, then navigating to the Keys page. - Replace
{{reg-app-tenant-id}}with the Tenant ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration - Replace
{{self-external-api-key}}with the unique GUID you generated when configuring themain.tffile.
- Replace
- Save your changes to the file
- Run the following commands:
-
npm ito install dependencies -
npm run buildto build the app -
npm prune --productionto tidy unused files
-
- Navigate to the web-app-external > package folder in your terminal
- Archive
dist,node_modules,package.jsonas a zip file, named web-app-external.zip
- Duplicate the example.settings.json file within the func-app-refresh folder in the code repo, and rename the copy to local.settings.json. Update the following values:
- Replace
{{company-name}}with the value set in the main.tf file. For example:contosouav - Replace
{{environment}}with the value set in the main.tf file. For example:uat - Replace
{{db-password}}with the password value set in the main.tf file - Replace
{{azure-search-key}}with the Primary Key found in the Azure Search service in your Resource Group, on the Keys page - Replace
{{reg-app-cert-thumbprint}}with the Certificate Thumbprint from the Certificate uploaded to your App Registration. You can obtain this value by opening the govaddressbook-app App Registration, then navigating to the Keys page. - Replace
{{reg-app-id}}with the ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration - Replace
{{reg-app-tenant-id}}with the Tenant ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration
- Replace
- Save your changes to the file
- Run the following commands:
-
npm ito install dependencies -
npm run buildto build the app -
npm prune --productionto remove unnecessary files
- Archive the following files into a zip folder called func-app-refresh.zip:
dist,node_modules,funcCompleteUserProfileNotification,funcDeleteUser,funcUpdateUserOOF,funcUserInfoFullMigration,funcUserInfoSync,proxies.json,host.json,package.json
- In a text editor, open the manifest.json file, found in the code repo > web-app-teams > package folder
- Update the following values:
- Replace
{{reg-app-id}}with the ID of the govaddressbook-app App Registration. You can obtain this value from the Overview page of the App Registration
- Replace
- Save your changes to the file
- Zip the contents of the manifest folder and call the new file govaddressbook-app.zip
-
cdto theweb-app-teamsfolder - Run
az login --tenant <your tenant id>in your shell terminal to login to your tenant - Using the zip folder you created previously, run the following command in your shell terminal to deploy the web app:
az webapp deployment source config-zip -g {{company-name}}-{{environment}}-directory-rg -n {{company-name}}-{{environment}}-directory-teams --src <replace by full local path of .zip package>
-
cdto theweb-app-externalfolder - Run
az login --tenant <your tenant id>in your shell terminal to login to your tenant - Using the zip folder you created previously, run the following command in your shell terminal to deploy the external web app:
az webapp deployment source config-zip -g {{company-name}}-{{environment}}-directory-rg -n {{company-name}}-{{environment}}-directory-external --src <replace by full local path of .zip package>
-
cdto thefunction-app-refreshfolder - Run
az login --tenant <your tenant id>in your shell terminal to login to your tenant - Using the zip folder you created previously, run the following command in your shell terminal to deploy the function app:
az functionapp deployment source config-zip -g {{company-name}}-{{environment}}-directory-rg -n {{company-name}}-{{environment}}-directory-refresh --src <replace by full local path of .zip package>
- Deploy the Teams app using the tools provided within the Teams Admin Centre.
The Terraform deployment is currently configured to deploy resources with a 'free' or 'basic' SKU where possible. Some of these SKUs, such as free App Services, have limitations.

You may need to modify the main.tf deployment configuration to accommodate your specific Azure subscription constraints.
We expect to update the default resource configuration in a future release.
By default, Key Vaults are soft-deleted when they are deleted from your Azure Subscription. If you hit an error in deployment with a code VaultAlreadyExists, you may still have a previously soft-deleted Key Vault that must be purged before continuing with the deployment