Creating Voice Routes and Routing Policies
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 10 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Configuring Direct Routing: Voice Routes and Routing Policies
Introduction: The Backbone of Enterprise Telephony
In the landscape of modern enterprise communication, Microsoft Teams has evolved from a simple chat and collaboration tool into a full-fledged telephony platform. While many organizations opt for Microsoft's native calling plans, there is a significant segment of the market that requires more control, flexibility, or cost-efficiency. This is where Direct Routing comes into play. Direct Routing allows your organization to connect its own Session Border Controller (SBC) to the Microsoft Phone System, effectively bridging your existing telecommunications infrastructure—such as SIP trunks or legacy PBX systems—with the cloud-based Teams environment.
Understanding how to configure Voice Routes and Voice Routing Policies is the most critical step in this implementation. Think of these components as the "traffic controllers" of your phone system. Without them, Teams would not know where to send an outbound call, which gateway to use, or which users are authorized to make specific types of calls. Mastering this configuration is not just about making phones ring; it is about building a reliable, secure, and cost-effective communication path that aligns with your organization's unique geographic and operational requirements.
In this lesson, we will peel back the layers of Direct Routing configuration. We will move beyond the basic setup and dive into the logic of how Microsoft Teams processes dialing patterns, how to segment your users into specific routing policies, and how to ensure that your telephony environment is built to handle complex global requirements. By the end of this guide, you will have the knowledge to design a routing architecture that is both functional and easy to maintain.
Not read yet
Understanding the Core Components
Before we write a single line of PowerShell, it is essential to understand the three primary building blocks of Direct Routing. These components work in a hierarchical sequence to determine the fate of a call.
- Online Voice Gateways: These are the SBCs you have configured in your environment. They represent the physical or virtual connection point where your traffic exits the Microsoft cloud and enters the PSTN (Public Switched Telephone Network).
- Voice Routes: A route is essentially a rule that tells the system: "If a user dials a number that matches this pattern, send it to this specific gateway." Routes are defined by Regular Expressions (RegEx) that match dial strings.
- Voice Routing Policies (VRP): A policy is a collection of one or more voice routes. You assign these policies to individual users. This allows you to control which users have access to which routes (e.g., your US employees might have access to a US-based gateway, while your UK employees use a different local gateway).
Callout: The Logic Hierarchy The progression of a call in Teams Direct Routing follows a strict logic path:
- User initiates a call.
- Teams checks the user's assigned Voice Routing Policy.
- The policy provides a list of Voice Routes.
- Teams checks the dialed number against the RegEx patterns in those routes.
- If a match is found, the call is routed to the associated Voice Gateway.
Not read yet
Step 1: Defining Voice Routes
A Voice Route is the bridge between a dialed number and a gateway. To create an effective route, you must understand Regular Expressions (RegEx). While RegEx can seem intimidating, the patterns used in Teams are generally straightforward.
The Anatomy of a RegEx Pattern
In Teams, the pattern ^(\+1)(\d{10})$ is a common example. Let’s break it down:
^: Start of the string.(\+1): Matches the literal characters "+1".(\d{10}): Matches exactly 10 digits.$: End of the string.
This pattern ensures that only calls starting with "+1" followed by 10 digits are routed through this specific path. If a user dials an extension or an international number, this route will be ignored, and the system will look for another match.
Creating a Route with PowerShell
To create a route, you use the New-CsOnlineVoiceRoute cmdlet. Let’s look at a practical example where we create a route for a North American gateway.
# Create a voice route for North American calls
New-CsOnlineVoiceRoute -Identity "NorthAmericaRoute" `
-NumberPattern "^(\+1)(\d{10})$" `
-OnlinePstnGatewayList "sbc.yourcompany.com" `
-Priority 1
Explanation of the parameters:
-Identity: A unique name for your route. Make it descriptive, such as "US-Local-Route" or "Global-Backup-Route."-NumberPattern: The RegEx rule.-OnlinePstnGatewayList: The FQDN of the SBC you previously registered in the Teams admin center.-Priority: This is vital. If multiple routes match a dialed number, the route with the lower number (higher priority) is chosen.
Tip: Managing Priorities Always leave gaps in your priority numbering (e.g., use 1, 10, 20 instead of 1, 2, 3). This allows you to insert a new route in the middle of your logic later without having to renumber every existing route in your environment.
Not read yet
Step 2: Configuring Voice Routing Policies
Once your routes are defined, you need to group them into a policy. A Voice Routing Policy is what you actually assign to a user. Without being part of a policy, a route is essentially orphaned and will never be used.
Why use multiple policies?
You might wonder why you wouldn't just have one policy for the entire company. The reality of global business dictates otherwise. You may have users in different countries who must use local gateways to comply with local regulations (like emergency calling requirements) or to avoid expensive long-distance charges.
Creating the Policy
Use the New-CsOnlineVoiceRoutingPolicy cmdlet to group your routes.
# Create a policy that includes the North America route
New-CsOnlineVoiceRoutingPolicy -Identity "NorthAmericaPolicy" `
-OnlinePstnUsages "NorthAmericaUsage" `
-Route "NorthAmericaRoute"
Wait, what is OnlinePstnUsages? This is an often-confusing concept for beginners. Think of PstnUsage as a "tag." You tag a route with a usage, and you tag a policy with that same usage. It acts as a middle-man to ensure that only authorized routes are included in a policy.
The Full Workflow: Route -> Usage -> Policy
- Define Usage:
Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="NorthAmericaUsage"} - Create Route with Usage: Add the usage to the
New-CsOnlineVoiceRoutecommand. - Create Policy with Usage: Add the usage to the
New-CsOnlineVoiceRoutingPolicycommand.
Not read yet
Advanced Routing Scenarios: Failover and Load Balancing
In a production environment, reliability is paramount. You should never rely on a single SBC. If that gateway goes down, your users lose the ability to make calls. Direct Routing allows for simple failover and load-balancing configurations.
Load Balancing
To load balance between two SBCs, you simply list both gateways in the OnlinePstnGatewayList parameter. Teams will automatically distribute calls across the listed gateways.
# Load balancing between two gateways
New-CsOnlineVoiceRoute -Identity "LoadBalancedRoute" `
-NumberPattern ".*" `
-OnlinePstnGatewayList "sbc1.company.com", "sbc2.company.com" `
-Priority 5
Failover
Failover works by the order of the gateways in the list. Teams will attempt the first gateway. If it receives a 5xx error or a timeout, it will move to the second gateway in the list. This provides a safety net for your telephony traffic.
Callout: Gateway Health While load balancing is great for traffic distribution, remember that the SBCs must be configured to handle the traffic. If you have two SBCs, ensure they both have the necessary SIP trunk capacity to handle the load if one of them fails and the other has to take 100% of the traffic.
Not read yet
Best Practices and Industry Standards
Implementing Direct Routing is as much about planning as it is about configuration. Here are the industry-standard best practices to ensure your deployment remains stable.
1. Standardize Your Naming Conventions
Use a consistent naming convention for your routes and policies. For example, use [Region]-[Type]-[Purpose].
- Example:
US-Local-E911,UK-Intl-Standard,DE-Backup-Route. - This makes troubleshooting significantly easier when you are looking at hundreds of lines of PowerShell output.
2. E911 and Emergency Calling
Never treat emergency calling as an afterthought. Your routing must ensure that emergency calls are directed to the most appropriate gateway that provides location-based routing. Many regions have strict legal requirements regarding where emergency calls can originate. Ensure your NumberPattern for emergency services is prioritized correctly and tested thoroughly.
3. Keep RegEx Simple
Avoid overly complex RegEx patterns. While it is possible to write a single complex expression for every possible number, it is much harder to troubleshoot when that specific expression fails. It is better to have five simple, readable routes than one massive, unreadable one.
4. Use Test-CsEffectivePSTNRoute
Microsoft provides a powerful tool to verify your configuration before you put it into production. Use the Test-CsEffectivePSTNRoute cmdlet to simulate a call.
# Simulate a call to see which route is selected
Test-CsEffectivePSTNRoute -Identity "[email protected]" -DialedNumber "+15550101234"
This command will tell you exactly which policy, route, and gateway the user would hit. Run this for every user profile type you have configured.
Not read yet
Common Pitfalls and How to Avoid Them
Even experienced administrators can fall into traps when configuring Direct Routing. Here are the most frequent mistakes and how to avoid them.
Pitfall 1: Forgetting to assign the policy
You can create the perfect route and the perfect policy, but if you don't assign the policy to the user, the user will have no calling capability.
- The Fix: Use
Grant-CsOnlineVoiceRoutingPolicy -Identity "[email protected]" -PolicyName "NorthAmericaPolicy". Always verify the assignment withGet-CsOnlineUser -Identity "[email protected]" | Select-Object OnlineVoiceRoutingPolicy.
Pitfall 2: The "Global" Usage Trap
Many admins use the "Global" PSTN usage for everything. While this works, it makes it difficult to manage complex environments later.
- The Fix: Create specific usages for specific regions or departments. It keeps your configuration clean and makes it easier to audit which policies have access to which routes.
Pitfall 3: Ignoring SIP Signaling Issues
Sometimes the route is correct, but the call fails because the SBC rejects the SIP invite.
- The Fix: Always check your SBC logs. If the Teams side shows the call was sent to the gateway, but the call drops, the issue is almost always on the SBC side or the SIP trunk provider. Use the SIP trace tools provided by your SBC vendor.
Pitfall 4: Misconfigured Number Normalization
If you are sending numbers to the SBC in an format it doesn't recognize (e.g., "+1" vs "001"), the carrier will reject the call.
- The Fix: Understand the expected format of your carrier. If your carrier expects "1" instead of "+1", you may need to use normalization rules on the SBC to strip the plus sign before passing the call to the carrier.
Not read yet
Comparison Table: Direct Routing vs. Operator Connect
To help you understand where Direct Routing fits in the broader ecosystem, it is useful to compare it to the other primary PSTN connectivity option: Operator Connect.
| Feature | Direct Routing | Operator Connect |
|---|---|---|
| Control | Full control over SBC and trunk | Managed by the operator |
| Complexity | High (Requires SBC management) | Low (Operator handles integration) |
| Flexibility | High (Can connect any legacy PBX) | Limited to operator offerings |
| Deployment Time | Weeks/Months | Days |
| Maintenance | Requires internal expertise | Managed by operator |
Direct Routing is the choice for organizations that need to maintain their existing carrier contracts, have complex local breakout requirements, or need to bridge Teams with legacy hardware.
Step-by-Step Configuration Checklist
When you are ready to configure your environment, follow this structured workflow to ensure nothing is missed:
Pre-requisites:
- Verify your SBC is certified for Microsoft Teams.
- Ensure your domain is verified in the Microsoft 365 admin center.
- Configure your SBC to accept traffic from Microsoft’s SIP proxies.
Register the Gateway:
- Use
New-CsOnlinePstnGatewayto register the SBC in Teams.
- Use
Define PSTN Usages:
Set-CsOnlinePstnUsageto create the labels you will use to categorize your routes.
Create Voice Routes:
New-CsOnlineVoiceRoutefor each destination pattern.- Associate each route with a PSTN usage.
Create Routing Policies:
New-CsOnlineVoiceRoutingPolicy.- Add the necessary PSTN usages to these policies.
Assign Policies:
Grant-CsOnlineVoiceRoutingPolicyto your users.
Verification:
- Use
Test-CsEffectivePSTNRoutefor each user type. - Place a test call from a Teams client and check the SBC logs.
- Use
Not read yet
Advanced PowerShell Scripting for Bulk Management
As your organization grows, you will not want to assign policies one by one. You will need to use PowerShell to automate the process for large groups of users.
Bulk Assignment Example
Suppose you have a CSV file with a list of users who all belong to the "NorthAmericaPolicy." You can use the following script to assign the policy in bulk:
# Import users from a CSV file
$users = Import-Csv "C:\Temp\UsersToUpdate.csv"
foreach ($row in $users) {
$upn = $row.UserPrincipalName
Write-Host "Assigning policy to $upn"
Grant-CsOnlineVoiceRoutingPolicy -Identity $upn -PolicyName "NorthAmericaPolicy"
}
This approach saves hours of manual work and ensures that your configuration is applied consistently across your entire user base. Always ensure your CSV is clean and contains valid User Principal Names (UPNs) before running bulk operations.
Troubleshooting: When Calls Fail
Troubleshooting telephony is an exercise in elimination. When a user reports that they cannot make a call, follow this diagnostic process:
- Check the Teams Client: Does the dial pad appear? If not, the user is likely not assigned a Phone System license or a phone number.
- Check User Policy: Run
Get-CsOnlineUser -Identity "[email protected]" | Select-Object OnlineVoiceRoutingPolicy. Is the policy assigned correctly? - Verify Route Logic: Use
Test-CsEffectivePSTNRouteto see if the system finds a valid path. If it returns null, your RegEx pattern or usage tags are mismatched. - Analyze SBC Logs: If the route is found, the call is hitting your SBC. Open your SBC management console. Are you seeing an incoming SIP invite from the Microsoft IP addresses?
- Carrier Check: If the SBC receives the invite but the call fails, look at the SIP error code. A
403 Forbiddenoften means a caller ID issue or an authentication failure with the carrier. A404 Not Foundusually means the carrier does not recognize the dialed number format.
Not read yet
Security Considerations
Direct Routing opens a door between your internal network (via the SBC) and the public cloud. Securing this path is critical.
- SBC Hardening: Ensure your SBC is not exposed to the public internet. Use Access Control Lists (ACLs) to only allow traffic from Microsoft’s specific IP ranges.
- SIP TLS: Always use TLS for SIP signaling. Never use unencrypted SIP (UDP/5060) for production traffic.
- Certificate Management: Your SBC must use a certificate from a trusted Root Certificate Authority (CA) that Microsoft recognizes. Keep track of certificate expiration dates, as an expired certificate will bring down all telephony traffic instantly.
- Least Privilege: When creating administrative accounts for managing voice routing, use the "Teams Communications Administrator" role rather than a Global Admin account.
Summary and Key Takeaways
Configuring Direct Routing is a foundational skill for any Teams Administrator. It requires a balance of logical planning, precise PowerShell configuration, and an understanding of how voice traffic behaves in a cloud-hybrid environment. By following the steps outlined in this lesson, you can build a telephony system that is resilient, scalable, and tailored to your organization’s needs.
Key Takeaways:
- Hierarchical Logic: Remember the sequence: User -> Policy -> Usage -> Route -> Gateway. If one link in this chain is broken or misconfigured, the call will fail.
- RegEx Precision: Your Voice Routes are only as good as your Regular Expressions. Test your patterns thoroughly to ensure they match only what you intend to route.
- The Power of PSTN Usages: Do not skip the PSTN Usage step. It is the glue that keeps your routing policies and routes organized and ensures that policies only contain the routes they are authorized to use.
- Verification is Mandatory: Never assume a configuration works. Use
Test-CsEffectivePSTNRoutefor every new policy or route you create. - Failover is Non-Negotiable: Always define multiple gateways in your routes to ensure that a single SBC failure does not result in an outage.
- Documentation: Keep a clear map of your routing logic, especially as your company expands. A well-documented routing policy is easy to troubleshoot; a poorly documented one is a nightmare during an outage.
- Security First: Treat your SBC as a critical security perimeter. Use TLS, restrict traffic to Microsoft IPs, and manage your certificates proactively.
By mastering these components, you ensure that your organization’s communication stays clear, reliable, and efficient, regardless of the complexity of your global infrastructure. Telephony is a high-stakes environment, but with a methodical approach to routing and policies, you can provide a seamless experience for your users.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
- Planning for Teams Meetings Webinars and Town Halls
- Teams Meetings Planning Quiz5q
- Designing Teams Meeting Policies and Settings
- Meeting Policies Design Quiz5q
- Planning for PSTN Audio Conferencing
- PSTN Audio Conferencing Quiz5q
- Recommending Teams Premium and Copilot
- Teams Premium Copilot Quiz5q
- Recommending Meeting Types Based on Requirements
- Meeting Types Quiz5q
- Policy Assignment Methods and Policy Packages
- Policy Assignment Quiz5q
- Identifying Licensing for Teams Phone
- Teams Phone Licensing Quiz5q
- Identifying PSTN Connectivity Requirements
- PSTN Connectivity Quiz5q
- Planning for Teams Phone Mobile and Operator Connect
- Teams Phone Mobile Quiz5q
- Planning SMS and Billing Methods
- SMS Billing Methods Quiz5q
- Planning Shared Calling and Phone Numbers
- Shared Calling Quiz5q
- Designing Auto Attendant and Call Queue Flows
- Auto Attendant Call Queue Quiz5q
- Designing Dynamic Emergency Calling
- Dynamic Emergency Calling Quiz5q
- Recommending Devices and Direct Routing
- Devices Direct Routing Quiz5q
Spend your points to unlock exam-style practice questions
Spend points to unlock MS-721 exam-style practice questions.
Practice for MS-721