Adding Virtual SBC for Teams Direct Routing To Office 365


This guide will help you configure Direct Routing for Microsoft Teams to Zapappi’s Virtual SBC for Teams if you decide to use a manual process. We don't advise you follow this guide, but instead use our Direct Routing automation tools.

You may find this resource helpful when trying to create a PowerShell connection to Microsoft Teams:


  1. You have PowerShell installed on the administration machine
  2. You have a Teams Admin account that has full access to the team’s role
  3. You have the Microsoft Teams PowerShell connector installed (Microsoft Teams PowerShell Overview - Microsoft Teams | Microsoft Docs)

1.  Add the FQDN assigned to the Tenant to Teams

For reference, see:

Assign at least one user to the new subdomain to active the subdomain in Office 365

2. Initiate PowerShell Connection

Create a connection to Microsoft Teams from within PowerShell. Running the code below, will initiate the required module, set execution permissions, and complete the connection. You will be asked to sign-in to Microsoft during this process, and perform Two Factor Authentication, if required on your account.

# When using Teams PowerShell Module 1.1.6
Import-Module MicrosoftTeams
$credential = Get-Credential
$sfbSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfbSession
# When using Teams PowerShell Module 2.0 or later
Import-Module MicrosoftTeams
$credential = Get-Credential
Connect-MicrosoftTeams -Credential $credential

3. Enable User(s) for Calling

For each user, make sure they have the correct license (e.g. E3 with Phone System). Then, run the following command (per user) to enable calling for them.

Powershell> Set-CsUser -Identity "<User name>" -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI tel:<E.164 Tel Number>

The phone numbers will be provided by Zapappi. You can only use phone numbers supplied by Zapappi with your Teams SBC account.

Repeat this for each user in your organisation.

When adding a number, be sure to prefix it in e164 format (e.g. +441232134567).

4. Configure PSTN Usage

We’re going to create a PSTN Usage called “All”. This will be the policy we use for routing all calls between Virtual SBC for Teams and Teams.

Powershell> Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="All"}

5. Configure Online Voice Routing

We’re going to define how calls are routed using a match (regular expression). To ensure all calls are passed to Virtual SBC for Teams Teams SBC, we’re going to make our Route match any digits dialled.

Powershell> New-CSOnlineVoiceRoute -Identity “All" -NumberPattern ".*" -OnlinePstnGatewayList <SBC FQDN> -Priority 1 -OnlinePstnUsages "All"

6. Create Online Voice Routing Policy

This step now links our voice route and Usages.

Powershell> New-CSOnlineVoiceRoutingPolicy "CallAnywhere" -OnlinePstnUsages "All"

7. Grant Voice Routing Policy to User

Now we can link our Voice Routing Policy to a user.

Powershell> Grant-CsOnlineVoiceRoutingPolicy -Identity <User> -PolicyName “CallAnywhere”

Repeat this for each user in your Organisation.