Microsoft Teams Direct Routing

Route calls between Microsoft Teams and the SIPcity network using 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:

  • Domain validation. Microsoft creates a TXT record to confirm you control your Direct Routing domain. You paste it into the portal, SIPcity publishes it in DNS automatically, and you confirm the domain with one command. You don’t change your own DNS.
  • 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.
  • Numbers, network and routing. SIPcity provides your numbers, connects calls to the phone network, and generates the PowerShell commands for your own domain and users.

Before you start

  • Microsoft licences. Each Teams user needs a Microsoft 365 licence that includes phone services (such as E1, E3 or E5) plus the Teams Phone Standard add-on. Manage licences in the Microsoft 365 admin center under Billing › Licenses.
  • Microsoft administrator account. You sign in to Microsoft 365 and Microsoft Teams as an administrator during setup.
  • SIPcity Account Administrator. You need an Account Administrator login for the SIPcity portal.
  • A Windows or macOS computer to run PowerShell. Step 1 of the guide shows how to install it.

1. Set up your Teams numbers in the SIPcity portal

Make each number a Teams line:

  1. In the SIPcity portal, select Numbers and select the number.
  2. On the Profile tab, set Type to Teams.
  3. Choose a Microsoft Teams plan, for example MS Teams User.
  4. Select Save.

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.

2. Assign a Teams user to each number

  1. Select Microsoft Teams under Manage.
  2. At the top of the page is your Direct Routing domain, for example ms50000100.teams.sipcity.com.au. It’s unique to your account.
  3. Beside each number, enter the Teams user’s email address, for example [email protected].
  4. Turn Voicemail on or off for each number.
  5. Select Save.

The PowerShell guide uses these emails and voicemail settings to build your commands, so set them up before you start the guide.

3. Run the PowerShell setup 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.

Step 1: Install PowerShell

Windows

  1. Check you’re running a supported version of Windows. Most versions include PowerShell, but you may need to update it.
  2. Download the MSI installer for your system (64-bit or 32-bit) from the PowerShell releases page, run it, and follow the instructions.
  3. Open a command prompt or PowerShell window and run pwsh to check it works.

macOS

  1. Check your version of macOS supports PowerShell.
  2. Install with Homebrew (recommended). Install Homebrew if you don’t have it yet, then run this in Terminal:
brew install --cask powershell
  1. Or download the .pkg file for macOS from the PowerShell releases page and run it.
  2. Open Terminal and run pwsh to check it works.

Step 2: Domain

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)

  1. Paste the code into the TXT record box in this guide.
  2. Select Add TXT record — this starts a 5-minute timer. SIPcity publishes the record to DNS instantly.
  3. Switch straight back to PowerShell and run:
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.

Step 3: User

Microsoft requires at least one licensed user on your Direct Routing domain before it can be used for Direct Routing.

Check whether a user exists

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.

Create a new user

  1. Sign in to the Microsoft 365 admin center with an administrator account.
  2. Open Users, then Active users, and select Add a user.
  3. Create the user on your Direct Routing domain, for example [email protected].
  4. Assign it at least one Office 365 Business licence.

Step 4: PSTN gateway

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

Step 5: Associate users

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.

Adding more Teams users later

You don’t need to repeat the domain, user, PSTN gateway or voice route steps. For each new user:

  1. In the SIPcity portal, set the number’s Type to Teams on its Profile tab, and select Save.
  2. Create the user in the Microsoft 365 admin center, with a licence that includes Teams Phone.
  3. On the SIPcity Microsoft Teams page, enter the user’s email beside the number, choose voicemail, and select Save.
  4. Open the PowerShell guide, go to Associate users, and run the commands for that number only.

Troubleshooting

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.

Was this article helpful?

Let us know so we can keep improving our guides.

Thank you for your feedback!

This form is only for article feedback. If you require assistance, please contact Support. How can we improve this page?

Related Articles

Still need help?

Our support team can help you get connected.