Voice for Microsoft Teams Setup

Microsoft Teams Trunks in VI Back Office

To set up your Microsoft Teams trunks in the Back Office, you will need to go to Endpoints > Microsoft Teams Trunks.


At this page, you will click the Create New Microsoft Teams Trunk button. 

You will be prompted with the following input fields:

  1. Trunk Name

    1. This is a friendly name for your Microsoft Teams Trunk within the Back Office.

  2. Subdomain

    1. This is the subdomain name you wish to use for your Microsoft Teams Instance.

After you have entered in that information, you will want to click Create Trunk. If successful you will receive a success message that it was submitted.


Adding a Custom Domain to Microsoft via Azure Active Directory Portal

The following steps is a summary of documentation from Microsoft: https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/add-custom-domain

Add New Domain to Azure AD

With the domain name provided entered in the Back Office, you can now add this to your Azure AD Directory.

Steps in adding the new domain according to Microsoft:

  1. Sign into the Azure Portal as a Global administrator account for the directory you are using.

  2. Search for and select “Azure Active Directory” from any page. Then select Custom Domain Names -> Add Custom Domain


  1. In Custom domain name, add the new domain name shown in the Back Office under the Subdomain column on the Microsoft Teams Trunks page. (XXXXXX.teams.sangoma.com)


  1. After you have entered the now unverified domain, you will need to save the information to create a TXT record. This is needed so the Subdomain can be properly configured in the Back Office.

    1. The information you will need to paste into the Back Office will look like this:


Please copy the MS=ms######## and go back into the Back Office under Endpoints->Microsoft Teams Trunks. Click on the “Edit” button next to the trunk that matches the domain you created and put the information inside the pop-up:



Once the TXT record information is submitted, you’re ready to continue configuring Microsoft Teams.


You will also see the configured checkbox checked on the Microsoft Teams Trunks page in the Back Office.


After configuration has been completed, you will want to verify the domain back in the Azure AD Portal. 

  1. Find and select your new custom domain name in the list of your domains.


  1. You will see a “Verify Domain” section where you will click the “Verify” button.

    1. FYI this may take up to 24 hours to complete for propagation on Microsoft’s side

Assigning a User to New Domain (1 User needs to be created on the new domain)

This user will need an E3 with a Phone System license add-on or an E5 (which includes the phone system license) or the equivalent in your plan. If you're not sure if the add-on is needed, you can find out more information about your plan here: 


  1. You can create a new user by going to the “Azure Active Directory” menu item and then Users.

    1. Then find “+ New User”

  2. Select “Create User” and fill out the rest of the form, ensuring that the domain selected is the one that you have just verified. (XXXXX.teams.sangoma.com)

  3. Once this new user is created, you will be able to find the user in the list of users for your account under the Users menu option on the menu. 

  4. You will want to now click on the new user that was created for your new domain to view that new user.

  5. Next, click on “Licenses” which is located under the “Manage” section of the User menu.

  6. We will now want to apply the license to this user so voice calls can start. 

    1. To do this

      1. Click on “+ Assignments” and search for “Microsoft 365 Phone System

      2. Apply the license to the User

        1. If an E5 user then the license is included but it will be an add-on if not an E5 user.

        2. This may take some time to propagate.


Configure Voice Policy


To configure Microsoft Teams’ Voice Routing is done by running the following script in Powershell as an administrator filling out the “$tenant_domain” with the domain name chosen when setting up the Microsoft Teams Trunk which should match the domain name that was verified and now has a single user with a Phone system license on it:

$tenant_domain = "XXXXX.teams.sangoma.com"
$Route = "Route_SANSAY1"
$PSTNUsage = "Usage_SANSAY1"
$VoicePolicy = "VP_SANSAY1"
$NumPattern = ".*"
#Create PSTN Usage
Set-CsOnlinePstnUsage -Identity Global -Usage @{Add=$PSTNUsage}
#Create Voice Route
New-CsOnlineVoiceRoute -Identity $Route -NumberPattern $NumPattern -OnlinePstnGatewayList $tenant_domain -Priority 0 -OnlinePstnUsages $PSTNusage
#Create Voice Policy
New-CsOnlineVoiceRoutingPolicy $VoicePolicy
Set-CsOnlineVoiceRoutingPolicy $VoicePolicy -OnlinePstnUsages $PSTNusage

Configure Users with Voice Policy (These users do NOT need to be on your new domain)

For a user to be able to make/receive phone calls with MS Teams, they must have an E5 account or Phone System License add-on. Skip to step 5 if they already have these.

  1.  Log into the Azure Active Directory admin console (http://aad.portal.azure.com)

  2. Select the “Users” option in the left menu

  3. Click on the user you are configuring, then click on “Licenses” under the “Manage” section of the submenu

  4. Click +Assignments and search for Microsoft 365 Phone System and add it to the customer (This will be included for E5 accounts and does cost additional for E3 accounts)

  5.  In PowerShell, run the following script to add voice service and a DID to the customer:


$USER = "user@domain.tld"
$DID = "+1234567890"
$VoicePolicy = "VP_SANSAY1"
Set-CsPhoneNumberAssignment -Identity $USER -PhoneNumber $DID -PhoneNumberType DirectRouting
Grant-CsOnlineVoiceRoutingPolicy -Identity $USER -PolicyName $VoicePolicy


$USER = "user@domain.tld"
$DID = "+1234567890"
$VoicePolicy = "VP_SANSAY1"
Set-CsUser -Identity $USER -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:$DID
Grant-CsOnlineVoiceRoutingPolicy -Identity $USER -PolicyName $VoicePolicy


$USER = "user@domain.tld"
$DID = "+1234567890"
$VoicePolicy = "VP_SANSAY1"
Set-CsUser -Identity $USER -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:$DID
Grant-CsOnlineVoiceRoutingPolicy -Identity $USER -PolicyName $VoicePolicy

It can take some time after adding voice policies, but the user should be able to browse to “Calls” in Microsoft Teams and have a Dial pad along with a message saying “Your Number: +1 (234) 567-8901”


Point DID to Microsoft Teams Trunk

The last step after you have a configured Microsoft Teams trunk in the Back Office and you have direct routing set up with Microsoft Teams, is to point a DID to your Microsoft Teams trunk in the Back Office.


To do this is just like pointing a DID to an endpoint group.

  1. Go to the DIDs tab

  2. Go to Manage DIDs

  3. Find the DID you want to point to the Microsoft Teams Trunk

  4. Select Microsoft Teams as the route to option when viewing the DID configuration wizard

    1. See example in image below



After a 15 minute window of propagation, you can start testing your calls to ensure calls are routing properly.