AI Voice Agent
Never miss another call.
AI Voice Agent
Never miss another call.
Home » Help Centre » Apps & Integrations » Third-Party Apps » Microsoft Teams Direct Routing
Direct Routing connects your Microsoft 365 tenant to SIPcity, so Teams users can make and receive phone calls on SIPcity numbers. The SIPcity portal walks you through setup in five steps, and SIPcity automates the parts that usually take the longest.
What SIPcity does for you:
Make each number a Teams line:
The number now shows a T icon on the Numbers page and appears on the Microsoft Teams page. To order new numbers, select Numbers, then Add numbers.
ms50000100.teams.sipcity.com.au. It’s unique to your account.[email protected].The PowerShell guide uses these emails and voicemail settings to build your commands, so set them up before you start the guide.
On the Microsoft Teams page, select PowerShell guide. The guide has five steps: Install PowerShell, Domain, User, PSTN gateway and Associate users. A tick marks each step you’ve finished. Use Next and Back to move between steps.
Always copy commands from the guide, using the copy icon on each command. The guide fills in your own Direct Routing domain, numbers and users. The commands below use the example domain ms50000100.teams.sipcity.com.au.
pwsh to check it works.brew install --cask powershell
pwsh to check it works.This step adds your Direct Routing domain to your Microsoft 365 tenant and validates it.
1. Connect to Microsoft 365
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.ReadWrite.All","Domain.ReadWrite.All"
A browser window will open — sign in with your Microsoft 365 admin account.
2. Add your domain
New-MgDomain -BodyParameter @{Id="ms50000100.teams.sipcity.com.au";IsDefault=$false}
No output means it worked. If you see an error that the domain already exists, that’s fine — someone has already added it, so continue to Step 3.
3. Get your verification code
$MgVerificationCode = (Get-MgDomainVerificationDnsRecord -DomainId "ms12345678.teams.sipcity.com.au" | Where-Object {$_.RecordType -eq "Txt"}).AdditionalProperties.text
echo $MgVerificationCode
This prints a code like MS=ms12345678.
4. Publish and confirm (do these back-to-back — you have 5 minutes)
Confirm-MgDomain -DomainId "ms50000100.teams.sipcity.com.au"
No error output means Microsoft has verified your domain. If you get a verification error, the record expired — select Add TXT record again and run Confirm-MgDomain immediately. You can retry as many times as you need.
5. Check (optional)
(Get-MgDomain -DomainId "ms50000100.teams.sipcity.com.au").IsVerified
This should return True.
Certificate. SIPcity automatically issues a security certificate for your Direct Routing domain, using Let’s Encrypt. It encrypts the connection between Microsoft Teams and SIPcity. We’ll let you know when it’s ready. You can carry on with the next steps in the meantime, but Direct Routing won’t work until the certificate is in place.
Microsoft requires at least one licensed user on your Direct Routing domain before it can be used for Direct Routing.
1. Install and connect the Microsoft Teams module, then list the users on your domain:
Install-Module MicrosoftTeams
Import-Module MicrosoftTeams
Connect-MicrosoftTeams
Get-CsOnlineUser | Where-Object { $_.SipAddress -like "*@ms50000100.teams.sipcity.com.au" } | Format-Table AssignedPlan, Alias, SipAddress
2. Check that a user on your Direct Routing domain has a Teams plan assigned. If one does, go to step 4.
[email protected].The PSTN gateway points Microsoft Teams at your Direct Routing domain.
1. Connect to Microsoft Teams. Sign in with an administrator account.
Install-Module MicrosoftTeams Import-Module MicrosoftTeams Connect-MicrosoftTeams
2. Create the PSTN gateway:
New-CsOnlinePSTNGateway -FQDN ms50000100.teams.sipcity.com.au -SIPSignalingPort 5061 -MaxConcurrentSessions 100 -Enabled $true
3. Check the gateway was created:
Get-CsOnlinePSTNGateway
4. Optional: when you’re done, end your Microsoft Teams session:
Disconnect-MicrosoftTeams
1. Connect to Microsoft Teams, as in step 4.
2. Create the voice route and voice routing policy. Run these once for your tenant:
Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="VOIP"}
New-CsOnlineVoiceRoute -Identity "VOIP" -NumberPattern ".*" -OnlinePstnGatewayList "ms50000100.teams.sipcity.com.au" -Priority 1 -OnlinePstnUsages "VOIP"
New-CsOnlineVoiceRoutingPolicy -Identity "VOIP" -OnlinePstnUsages "VOIP"
3. Assign your numbers. The guide shows a set of commands for each Teams number, labelled with the number and its user’s email. Run them for each number:
Set-CsPhoneNumberAssignment -Identity "[email protected]" -PhoneNumber +61255500000 -PhoneNumberType DirectRouting Grant-CsTeamsCallingPolicy -PolicyName AllowCalling -Identity "[email protected]" Grant-CsOnlineVoiceRoutingPolicy -Identity "[email protected]" -PolicyName "VOIP" Set-CsOnlineVoicemailUserSettings -Identity "[email protected]" -VoicemailEnabled $false
Numbers are in international format, for example +61255500000. The last command turns voicemail on ($true) or off ($false) to match the Voicemail setting on the Microsoft Teams page.
If any number has no Teams user, the guide shows Some numbers have no Teams user and lists them. Select Back to Microsoft Teams, add the email beside each number, select Save, then return to the guide.
4. Select Finish. Your numbers are ready to use in Microsoft Teams once the certificate is in place.
You don’t need to repeat the domain, user, PSTN gateway or voice route steps. For each new user:
| Problem | What to do |
|---|---|
Confirm-MgDomain fails, or the domain still shows as unverified |
The 5-minute window may have passed and the TXT record has been removed. Select Add TXT record again, then run Confirm-MgDomain straight away. |
New-CsOnlinePSTNGateway fails in step 4 |
Check the domain was confirmed in step 2. If not, add the TXT record again and run Confirm-MgDomain. Also check a licensed user exists on the domain (step 3). |
| The guide says Some numbers have no Teams user | Select Back to Microsoft Teams, add the user’s email beside each listed number, select Save, and return to the guide. |
| Setup is finished but calls don’t work | The certificate may not be ready yet. Wait for our notification that it’s been created, then try again. |
| Calls fail after you copied commands from elsewhere | Check that the domain in the PSTN gateway and in the voice route is the same: your own Direct Routing domain, shown on the Microsoft Teams page. Copy commands from the guide to avoid this. |
| A user can’t make calls in Teams | Check the user has a licence with Teams Phone, and that you ran all four Assign your numbers commands for their number. |
| A command isn’t recognised | Run the connect commands for that step first: Microsoft Graph for the Domain step, and Connect-MicrosoftTeams for the User, PSTN gateway and Associate users steps. |
Still stuck? Contact SIPcity support and quote your account number.
Microsoft Teams, Microsoft Windows, and PowerShell are trademarks or registered trademarks of Microsoft Corporation in the US and other countries. macOS is a registered trademark of Apple Inc.
Let us know so we can keep improving our guides.
Thank you for your feedback!