Configure Voice Routing

Microsoft Phone System has a routing mechanism that allows a call to be sent to a specific SBC based on:

  • Called number pattern
  • Called number pattern + Specific User who makes the call

SBCs can be designated as active and backup. That means when the SBC that is configured as active for this number pattern, or number pattern + specific user, is not available, then the calls will be routed to a backup SBC.

Call routing is made up of the following elements:

  • Voice Routing Policy – container for PSTN Usages; can be assigned to a user or to multiple users
  • PSTN Usages – container for Voice Routes and PSTN Usages; can be shared in different Voice Routing Policies
  • Voice Routes – number pattern and set of Online PSTN Gateways to use for calls where calling number matches the pattern
  • Online PSTN Gateway – pointer at SBC, also stores the configuration that is applied when call is placed via the SBC, such as forward P-Asserted-Identity (PAI) or Preferred Codecs; can be added to Voice Routes

Creating a voice routing policy with one PSTN Usage

The following diagram shows two examples of voice routing policies in call flow.

Call Flow 1 (on the left): If a user makes a call to +1 425 XXX XX XX or +1 206 XXX XX XX, the call is routed to SBC sbc1.contoso.biz or sbc2.contoso.biz. If neither sbc1.contoso.biz nor sbc2.contoso.biz are available, the call is dropped.

Call Flow 2 (on the right): If a user makes a call to +1 425 XXX XX XX or +1 206 XXX XX XX, the call is first routed to SBC sbc1.contoso.biz or sbc2.contoso.biz. If neither SBC is available, the route with lower priority will be tried (sbc3.contoso.biz and sbc4.contoso.biz). If none of the SBCs are available, the call is dropped.

Shows voice routing policy examples

In both examples, while the Voice Route is assigned priorities, the SBCs in the routes are tried in random order.

Note

Unless the user also has a Microsoft Calling Plan license, calls to any number except numbers matching the patterns + +1 425 XXX XX XX or +1 206 XXX XX XX in the example configuration are dropped. If the user has a Calling Plan license, the call is automatically routed according to the policies of the Microsoft Calling Plan.

The Microsoft Calling Plan applies automatically as the last route to all users with the Microsoft Calling Plan license and does not require additional call routing configuration.

In the example shown in the following diagram, a voice route is added to send calls to all other US and Canadian number (calls that go to called number pattern +1 XXX XXX XX XX).

Shows voice routing policy with a third route

For all other calls, if a user has both licenses (Microsoft Phone System and Microsoft Calling Plan), Automatic Route is used. If nothing matches the number patterns in the administrator-created online voice routes, route via Microsoft Calling Plan.

If the user has only Microsoft Phone System, the call is dropped because no matching rules are available.

Note

The Priority value for route “Other +1” doesn’t matter in this case, as there is only one route that matches the pattern +1 XXX XXX XX XX. If a user makes a call to +1 324 567 89 89 and both sbc5.contoso.biz and sbc6.contoso.biz are unavailable, the call is dropped.

The following table summarizes the configuration using three voice routes. In this example, all three routes are part of the same PSTN Usage “US and Canada”.

PSTN usageVoice routeNumber patternPrioritySBCDescription
US only“Redmond 1”^\+1(425|206)(\d{7})$1sbc1.contoso.biz
sbc2.contoso.biz
Active route for called numbers +1 425 XXX XX XX or +1 206 XXX XX XX
US only“Redmond 2”^\+1(425|206)(\d{7})$2sbc3.contoso.biz
sbc4.contoso.biz
Backup route for called numbers +1 425 XXX XX XX or +1 206 XXX XX XX
US only“Other +1”^\+1(\d{10})$3sbc5.contoso.biz
sbc6.contoso.biz
Route for called numbers +1 XXX XXX XX XX (except +1 425 XXX XX XX or +1 206 XXX XX XX)
      

All routes are associated with the PSTN Usage “US and Canada” and the PSTN Usage is associated with the Voice Routing Policy “US Only.” In this example, the voice routing policy is assigned to user Spencer Low.

Examples of call routes

In the following example, we demonstrate how to configure Routes, PSTN Usages, and Routing policies, and we assign the policy to the user.

Step 1: Create the PSTN Usage “US and Canada.”

In a Skype for Business Remote PowerShell session, type:

 
Set-CsOnlinePstnUsage  -Identity Global -Usage @{Add="US and Canada"}

Validate that the usage was created by entering:

 
Get-CSOnlinePSTNUsage

Which returns a list of names that may be truncated:

 
  Identity	: Global
  Usage    	: {testusage, US and Canada, International, karlUsage. . .}

In the example below, you can see the result of the running the PowerShell command (Get-CSOnlinePSTNUsage).usage to display full names (not truncated).

 testusage
 US and Canada
 International
 karlUsage
 New test env
 Tallinn Lab Sonus
 karlUsage2
 Unrestricted
 Two trunks

Step 2: In a PowerShell session in Skype for Business Online, create three routes: Redmond 1, Redmond 2, and Other+1, as detailed in the previous table.

To create the “Redmond 1” route, enter:

 
New-CsOnlineVoiceRoute -Identity "Redmond 1" -NumberPattern "^+1(425|206)
(\d{7})$" -OnlinePstnGatewayList sbc1.contoso.biz, sbc2.contoso.biz -Priority 1 -OnlinePstnUsages "US and Canada"

Which returns:

Identity                : Redmond 1
Priority       		: 1
Description	     	:
NumberPattern 		: ^\+1(425|206) (\d{7})$
OnlinePstnUsages 	: {US and Canada}
OnlinePstnGatewayList	: {sbc1.contoso.biz, sbc2.contoso.biz}
Name		 	: Redmond 1
SuppressCallerId	:
AlternateCallerId	:

To create the Redmond 2 route, enter:

 
New-CsOnlineVoiceRoute -Identity "Redmond 2" -NumberPattern "^\+1(425|206)
(\d{7})$" -OnlinePstnGatewayList sbc3.contoso.biz, sbc4.contoso.biz -Priority 2 -OnlinePstnUsages "US and Canada"

To create the Other +1 route, enter:

 
New-CsOnlineVoiceRoute -Identity "Other +1" -NumberPattern "^\\+1(\d{10})$"
-OnlinePstnGatewayList sbc5.contoso.biz, sbc6.contoso.biz -OnlinePstnUsages "US and Canada"

Caution

Make sure that your regular expression in the NumberPattern attribute is a valid expression. You can test it using this website: https://www.regexpal.com

In some cases there is a need to route all calls to the same SBC; please use -NumberPattern “.*”

  • Route all calls to same SBC

     
  • Set-CsOnlineVoiceRoute -id "Redmond 1" -NumberPattern ".*" 
     -OnlinePstnGatewayList sbc1.contoso.biz
    

Validate that you’ve correctly configured the route by running the Get-CSOnlineVoiceRoute Powershell command using options as shown:

 
Get-CsOnlineVoiceRoute | Where-Object {($_.priority -eq 1) -or ($_.priority -eq 2) or ($_.priority -eq 4) -Identity "Redmond 1" -NumberPattern "^\+1(425|206) (\d{7})$" -OnlinePstnGatewayList sbc1.contoso.biz, sbc2.contoso.biz -Priority 1 -OnlinePstnUsages "US and Canada"

Which should return:

Identity	    	: Redmond 1 
Priority       		: 1
Description	 	: 
NumberPattern 		: ^\+1(425|206) (\d{7})$
OnlinePstnUsages 	: {US and Canada}	 
OnlinePstnGatewayList	: {sbc1.contoso.biz, sbc2.contoso.biz}
Name		 	: Redmond 1
Identity		: Redmond 2 
Priority       		: 2
Description	 	: 
NumberPattern 		: ^\+1(425|206) (\d{7})$
OnlinePstnUsages 	: {US and Canada}	 
OnlinePstnGatewayList	: {sbc3.contoso.biz, sbc4.contoso.biz}
Name		 	: Redmond 2
    
Identity		: Other +1 
Priority       		: 4
Description	 	: 
NumberPattern 		: ^\\+1(\d{10})$
OnlinePstnUsages 	: {US and Canada}	 
OnlinePstnGatewayList	: {sbc5.contoso.biz, sbc6.contoso.biz}
Name		 	: Other +1

In the example, the route “Other +1” was automatically assigned priority.

Step 3: Create a Voice Routing Policy “US Only” and add to the policy the PSTN Usage “US and Canada.”

In a PowerShell session in Skype for Business Online, type:

 
New-CsOnlineVoiceRoutingPolicy "US Only" -OnlinePstnUsages "US and Canada"

The result is shown in this example:

Identity	    : Tag:US only
OnlinePstnUsages    : {US and Canada}
Description    	    :
RouteType    	    : BYOT

Step 4: Grant to user Spence Low a voice routing policy by using PowerShell.

  • In a Powershell session in Skype for Business Online, type:

    Grant-CsOnlineVoiceRoutingPolicy -Identity "Spencer Low" -PolicyName "US Only"

  • Validate the policy assignment by entering this command:

 
Get-CsOnlineUser "Spencer Low" | select OnlineVoiceRoutingPolicy

Which returns:

    OnlineVoiceRoutingPolicy
    ---------------------
    US Only

Creating a Voice Routing Policy with several PSTN Usages

The Voice Routing Policy created previously only allows calls to phone numbers in the US and Canada–unless the Microsoft Calling Plan license is also assigned to the user.

In the example that follows, you can create the Voice Routing Policy “No Restrictions.” The policy reuses the PSTN Usage “US and Canada” created in the previous example, as well as the new PSTN Usage “International.”

This routes all other calls to the SBCs sbc2.contoso.biz and sbc5.contoso.biz. The examples that are shown assign US Only policy to user “Spencer Low,” and No Restrictions to the user “John Woods.”

Spencer Low – Calls allowed only to US and Canadian numbers. When calling to Redmond number range, the specific set of SBC must be used. Non-US numbers will not be routed unless the Calling Plan license is assigned to the user.

John Woods – Calls allowed to any number. When calling to Redmond number range, the specific set of SBC must be used. Non-US numbers will be routed via sbc2.contoso.biz and sbc5.contoso.biz.

Shows voice routing policy assigned to user Spencer Low

For all other calls, if a user has both licenses (Microsoft Phone System and Microsoft Calling Plan), Automatic Route is used. If nothing matches the number patterns in the administrator-created online voice routes, route via Microsoft Calling Plan.

If the user has only Microsoft Phone System, the call is dropped because no matching rules are available.

Shows voice routing policy assigned to user John Woods

The following table summarizes routing policy “No Restrictions” usage designations and voice routes.

PSTN usageVoice routeNumber patternPrioritySBCDescription
US Only“Redmond 1”^+1(425|206)(\d{7})$1sbc1.contoso.biz
sbc2.contoso.biz
Active route for callee numbers +1 425 XXX XX XX or +1 206 XXX XX XX
US Only“Redmond 2”^+1(425|206)(\d{7})$2sbc3.contoso.biz
sbc4.contoso.biz
Backup route for callee numbers +1 425 XXX XX XX or +1 206 XXX XX XX
US Only“Other +1”^+1(\d{10})$3sbc5.contoso.biz
sbc6.contoso.biz
Route for callee numbers +1 XXX XXX XX XX (except +1 425 XXX XX XX or +1 206 XXX XX XX)
InternationalInternational\d+4sbc2.contoso.biz
sbc5.contoso.biz
Route for any number pattern

Note

  • The order of PSTN Usages in Voice Routing Policies is critical. The usages are applied in order, and if a match is found in the first usage, then other usages are never evaluated. The PSTN Usage “International” must be placed after the PSTN Usage “US Only.” To change the order of the PSTN Usages, please run the Set-CSOnlineRouteRoutingPolicy command.
    For example, to change the order from “US and Canada” first and “International” second to the reverse order run:
    Set-CsOnlineVoiceRoutingPolicy -id tag:"no Restrictions" -OnlinePstnUsages @{Replace="International", "US and Canada"}
  • The priority for “Other +1” and “International” Voice routes are assigned automatically. They don’t matter as long as they have lower priorities than “Redmond 1” and “Redmond 2.”

Example of Voice Routing Policy for user John Woods

The steps to create PSTN Usage “International”, voice route “International,” Voice Routing Policy “No Restrictions,” and then assigning it to the user “John Woods” are as follows.

  1. First, create the PSTN Usage “International.” In a remote PowerShell session in Skype for Business Online, enter:

     
  • Set-CsOnlinePstnUsage  -Identity Global -Usage @{Add="International"}
    
  • Next, create the new voice route “International.”

     
  1. New-CsOnlineVoiceRoute -Identity "International" -NumberPattern "\d+" -OnlinePstnGatewayList sbc2.contoso.biz, sbc5.contoso.biz -OnlinePstnUsages "International"
    

    Which returns:

    Identity                  : International 
    Priority                      : 5
    Description                   : 
    NumberPattern                 : \d+
    OnlinePstnUsages          : {International}    
    OnlinePstnGatewayList           : {sbc2.contoso.biz, sbc5.contoso.biz}
    Name                            : International
    SupressCallerId           :
    AlternateCallerId         :
    
  2. Next, create a Voice Routing Policy “No Restrictions”. The PSTN Usage “Redmond 1” and “Redmond “ are reused in this voice routing policy to preserve special handling for calls to number “+1 425 XXX XX XX” and “+1 206 XXX XX XX” as local or on-premise calls.

 
New-CsOnlineVoiceRoutingPolicy "No Restrictions" -OnlinePstnUsages "US and Canada", ”International”
 
Take note of the order of PSTN Usages:

a. If a call made to number “+1425 XXX XX XX” with the usages configured as in the following example, the call follows the route set in “US and Canada” usage and the special routing logic is applied. That is, the call is routed using  sbc1<span></span>.contoso.biz and sbc2<span></span>.contoso.biz first, and then  sbc3<span></span>.contoso.biz and sbc4<span></span>.contoso.biz as the backup routes. 

b.	If “International” PSTN usage is before “US and Canada,” calls to + 1425 XXX XX XX are routed to sbc2<span></span>.contoso.biz and sbc5<span></span>.contoso.biz as part of the routing logic. Enter the command:

```New-CsOnlineVoiceRoutingPolicy "No Restrictions" -OnlinePstnUsages "US and Canada", ”International”```

Which returns

   Identity		: International 
   OnlinePstnUsages 	: {US and Canada, International}	 
   Description		:  
   RouteType	 	: BYOT
  
  1. Assign the voice routing policy to the user “John Woods” using the following command.

     
Grant-CsOnlineVoiceRoutingPolicy -Identity "John Woods" -PolicyName "No Restrictions”

Then verify the assignment using the command:

 
  1. Get CsOnlineUser “John Woods” | Select OnlineVoiceRoutingPolicy
    

    Which returns:

    OnlineVoiceRoutingPolicy
    ------------------------
    No Restrictions