There is an updated document for Microsoft Teams.
If you are an existing client who already has Microsoft Teams installed, please do not use this document, as it is intended for new installations only. Microsoft has updated the backend configuration for new clients, which differs from the version you are currently using.
Clients who implemented Teams prior to 2026 should use the link below.
Step 1: Add and Verify Domain
Web Portal
- Go to Microsoft 365 Admin Center (admin.microsoft.com)
- Navigate to Settings → Domains → Add domain
- Enter domain name (e.g., yourcompany.key2pbx.ca)
- Add the provided DNS TXT record to your domain registrar
- Wait 15-30 minutes for DNS propagation
- Click Verify
Step 2: Configure Session Border Controller (SBC)
Web Portal
- Go to Teams Admin Center (admin.teams.microsoft.com)
- Navigate to Voice → Direct Routing → SBCs
- Click + Add
- Configure:
- FQDN: yourcompany.key2pbx.ca
- Enabled: On
- SIP signaling port: 5061
- Max concurrent sessions: 100
- Click Save
PowerShell
connect to your tenant
# Connect using device code authentication
Connect-MicrosoftTeams -UseDeviceAuthentication# Verify connection
$connectionInfo = Get-CsTenant -ErrorAction Stop
Write-Host "Connected to tenant: $($connectionInfo.DisplayName)"
$sbcFqdn = "yourcompany.key2pbx.ca"
$sipPort = 5061
$maxConcurrentSessions = 100# Check if SBC exists
$existingSbc = Get-CsOnlinePSTNGateway -Identity $sbcFqdn -ErrorAction SilentlyContinueif ($existingSbc) {
# Update existing SBC
Set-CsOnlinePSTNGateway -Identity $sbcFqdn -SipSignalingPort $sipPort -MaxConcurrentSessions $maxConcurrentSessions -Enabled $true
} else {
# Create new SBC
New-CsOnlinePSTNGateway -Fqdn $sbcFqdn -SipSignalingPort $sipPort -MaxConcurrentSessions $maxConcurrentSessions -Enabled $true
}# Verify configuration
$sbcConfig = Get-CsOnlinePSTNGateway -Identity $sbcFqdn
Write-Host "FQDN: $($sbcConfig.Fqdn)"
Write-Host "SIP Port: $($sbcConfig.SipSignalingPort)"
Write-Host "Max Sessions: $($sbcConfig.MaxConcurrentSessions)"
Write-Host "Enabled: $($sbcConfig.Enabled)"
Step 4: Create PSTN Usage
Web Portal
- Go to Teams Admin Center → Voice → Direct Routing
- Click Voice routing policies tab → PSTN usage records tab
- Click + Add
- Enter name: "key2PSTNUsage"
- Click Save
Powershell
$pstnUsageName = "key2PSTNUsage"
# Check if usage exists
$currentUsage = Get-CsOnlinePstnUsageif ($currentUsage.Usage -contains $pstnUsageName) {
Write-Host "PSTN Usage $pstnUsageName already exists."
} else {
Write-Host "Creating PSTN Usage..."
Set-CsOnlinePstnUsage -Identity Global -Usage @{Add=$pstnUsageName}
}
Step 5: Create Voice Route
Web Portal
- Go to Voice → Direct Routing → Voice routes
- Click + Add
- Configure:
- Name: key2-Outbound-Route
- Dialed number pattern:
.*(matches all calls) - Priority: 1
- PSTN usage: key2PSTNUsage
- SBCs: yourcompany.key2pbx.ca
- Click Save
Powershell
$routeName = "key2-Outbound-Route"
$routePattern = ".*"
$sbcFqdn = "yourcompany.key2pbx.ca"
$pstnUsageName = "key2PSTNUsage"# Remove existing route if it exists
$existingRoute = Get-CsOnlineVoiceRoute -Identity $routeName -ErrorAction SilentlyContinue
if ($existingRoute) {
Remove-CsOnlineVoiceRoute -Identity $routeName -Confirm:$false
}# Create voice route with priority 1
New-CsOnlineVoiceRoute -Identity $routeName -NumberPattern $routePattern -OnlinePstnGatewayList $sbcFqdn -OnlinePstnUsages $pstnUsageName -Priority 1# Verify and update priority if needed
Start-Sleep -Seconds 2
$verifyRoute = Get-CsOnlineVoiceRoute -Identity $routeName
if ($verifyRoute.Priority -ne 1) {
Set-CsOnlineVoiceRoute -Identity $routeName -Priority 1 -Confirm:$false
}# Ensure this route has highest priority
$allRoutes = Get-CsOnlineVoiceRoute
$otherPriority1Routes = $allRoutes | Where-Object { $_.Identity -ne $routeName -and $_.Priority -le 1 }if ($otherPriority1Routes) {
$counter = 2
foreach ($route in $otherPriority1Routes) {
Set-CsOnlineVoiceRoute -Identity $route.Identity -Priority $counter -Confirm:$false
$counter++
}
}# Verify and Display configuration
$route = Get-CsOnlineVoiceRoute -Identity $routeName
Write-Host "Identity: $($route.Identity)"
Write-Host "Number Pattern: $($route.NumberPattern)"
Write-Host "Gateway: $($route.OnlinePstnGatewayList)"
Write-Host "Priority: $($route.Priority)"
Step 6: Create Voice Routing Policy
Web Portal
- Go to Voice → Voice routing policies
- Click + Add
- Configure:
- Name: key2-Voice-Policy
- PSTN usage records: Add "key2PSTNUsage"
- Click Save
Powershell
$policyName = "key2-Voice-Policy"
$pstnUsageName = "key2PSTNUsage"# Check if policy exists
$existingPolicy = Get-CsOnlineVoiceRoutingPolicy -Identity $policyName -ErrorAction SilentlyContinueif ($existingPolicy) {
# Update existing policy
Set-CsOnlineVoiceRoutingPolicy -Identity $policyName -OnlinePstnUsages @{Add=$pstnUsageName}
} else {
# Create new policy
New-CsOnlineVoiceRoutingPolicy -Identity $policyName -OnlinePstnUsages $pstnUsageName
}# Verify and Display configuration
$policy = Get-CsOnlineVoiceRoutingPolicy -Identity $policyName
Write-Host "Identity: $($policy.Identity)"
Write-Host "PSTN Usages: $($policy.OnlinePstnUsages -join ', ')"
Step 7: Assign Phone Numbers to Users
Web Portal
- Go to Teams Admin Center → Users → Manage users
- Select a user → Account tab
- Under Phone number, click Edit
- Configure:
- Phone number type: Direct Routing
- Phone number: +12065551234 (E.164 format) or extension (e.g., 1001)
- Click Save
Powershell
$userPrincipalName = "user@yourcompany.com"
$phoneNumber = "+14165551234" # or extension like "1001"# Check if user exists
$existingUser = Get-CsOnlineUser -Identity $userPrincipalName -ErrorAction SilentlyContinueif ($existingUser) {
# Assign phone number
Set-CsPhoneNumberAssignment -Identity $userPrincipalName -PhoneNumber $phoneNumber -PhoneNumberType DirectRouting
Write-Host "Phone number assigned"
}
Powershell
$userPrincipalName = "user@yourcompany.com"
$phoneNumber = "+12065551234" # or extension like "1001"# Check if user exists
$existingUser = Get-CsOnlineUser -Identity $userPrincipalName -ErrorAction SilentlyContinueif ($existingUser) {
# Assign phone number
Set-CsPhoneNumberAssignment -Identity $userPrincipalName -PhoneNumber $phoneNumber -PhoneNumberType DirectRouting
Write-Host "Phone number assigned"
}
Step 8: Enable Enterprise Voice
Enterprise Voice cannot be enabled through the web portal. Must use PowerShell.
Powershell
$userPrincipalName = "user@yourcompany.com"
# Enable Enterprise Voice
Set-CsUser -Identity $userPrincipalName -EnterpriseVoiceEnabled $true
Write-Host "Enterprise Voice enabled"
Step 9: Assign Voice Routing Policy
Web Portal
- Go to Users → Manage users
- Select user → Policies tab
- Under Voice routing policy, select "key2-Voice-Policy"
- Click Save
Powershell
$userPrincipalName = "user@yourcompany.com"
$policyName = "key2-Voice-Policy"# Assign voice routing policy
Grant-CsOnlineVoiceRoutingPolicy -Identity $userPrincipalName -PolicyName $policyName
Write-Host "Voice routing policy assigned"
Step 10: Verify User Configuration
Web Portal
- Go to Users → Manage users → Select user
- Check Account tab:
- Phone number is assigned
- Phone number type shows "Direct Routing"
- Check Policies tab:
- Voice routing policy is assigned
Powershell
$userPrincipalName = "user@yourcompany.com"
# Verify user configuration
$userConfig = Get-CsOnlineUser -Identity $userPrincipalName | Select-Object UserPrincipalName, LineUri, EnterpriseVoiceEnabled, OnlineVoiceRoutingPolicyWrite-Host "User: $($userConfig.UserPrincipalName)"
Write-Host "Phone Number: $($userConfig.LineUri)"
Write-Host "Enterprise Voice: $($userConfig.EnterpriseVoiceEnabled)"
Write-Host "Voice Policy: $($userConfig.OnlineVoiceRoutingPolicy)"
Complete Configuration (Full User Setup) via Powershell commands
PowerShell - Complete User Configuration
# Connect
Connect-MicrosoftTeams -UseDeviceAuthentication
$connectionInfo = Get-CsTenant -ErrorAction Stop# Define variables
$userPrincipalName = "user@yourcompany.com
$phoneNumber = "+4165551234" # or extension like "1001"
$policyName = "key2-Voice-Policy"# Check user exists
$existingUser = Get-CsOnlineUser -Identity $userPrincipalName -ErrorAction SilentlyContinueif ($existingUser) {
# Assign phone number
Set-CsPhoneNumberAssignment -Identity $userPrincipalName -PhoneNumber $phoneNumber -PhoneNumberType DirectRouting
# Enable Enterprise Voice
Set-CsUser -Identity $userPrincipalName -EnterpriseVoiceEnabled $true
# Assign voice routing policy
Grant-CsOnlineVoiceRoutingPolicy -Identity $userPrincipalName -PolicyName $policyName
# Verify configuration
$userConfig = Get-CsOnlineUser -Identity $userPrincipalName | Select-Object UserPrincipalName, LineUri, EnterpriseVoiceEnabled, OnlineVoiceRoutingPolicy
#diaply stored data
Write-Host "User: $($userConfig.UserPrincipalName)"
Write-Host "Phone Number: $($userConfig.LineUri)"
Write-Host "Enterprise Voice: $($userConfig.EnterpriseVoiceEnabled)"
Write-Host "Voice Policy: $($userConfig.OnlineVoiceRoutingPolicy)"
}# Disconnect
Disconnect-MicrosoftTeams
Troubleshooting
User Can't Make Calls
# Verify user configuration
Get-CsOnlineUser -Identity user@yourcompany.com | Select-Object LineUri, EnterpriseVoiceEnabled, OnlineVoiceRoutingPolicy
Help Center