Creating custom normalization rules in Office365

We are all used to typing the numbers we want to reach, and magically, Skype for Business knows in which country you want to dial. Note that in order to actually reach to a PSTN endpoint, you have to dial the number in E.164 format.

To get a little bit into specifics, the E.164 number is constructed from: Country Code + Area Code +  Subscriber Access number. For example my fixed landline might be: +40268500xxx, where:

  • +40 is the Country Code for Romania
  • 268 is the Area Code for Brasov (yeah, I’m from Dracula’s land)
  • And 500xxx is the actual Subscriber Access number.

But wait, when people try to reach me from within the country, or even from within the same Area Code, they will not write the whole number. Instead, they will most likely call 268500xxx.

This is where the Dial Plans and the magical normalization rules come into play.

With Office365, based on your Usage Location, you will also get automatically assigned with a Dial Plan specific for your country.

For example, I’ve set a user with UsageLocation set on UK and automatically, this user has a UK Dial Plan:

Now, if I query this Dial plan, we will see a couple of normalization rules in effect:

Here, for example we can see the “GB Intl Dialing” normalization rule which says:

If you detect this pattern: ^00(\d+)$, translate to +$1. What it actually means is: If a number starts with “00”, replace it with a + sign. Why is that? Because people are used to dial 00 instead of the + sign. So if wanting to call a US number, people might dial 001xxx instead of +1 (remember, we have to have the numbers in E.164 format).

Now, what happens when the Normalization Rules predefined in the automatically assigned Dial Plan are not enough? Well, here is where the Tenant Dial Plan kicks-in. Sweet!

I have seen the ask where O365 users would like to have a short number for internal emergencies. For example, dialing 400 from Skype for Business, should ring at +40268500xxx.

Here is how to accomplish that:

First we will create a variable which will contain the value for a New Normalization rule where we define the pattern that we would like to be normalized:

$nr1 = New-CsVoiceNormalizationRule -Identity testA/nr1 -Description “TestA” -Pattern ‘^400$’ -Translation ‘+40268500xxx’ -InMemory

Next, we will create a new Tenant Dial Plan and add the newly normalization rules to it:

New-CsTenantDialPlan -Identity testA -NormalizationRules @{Add=$nr1}

!Note that I’ve wrote “rules” because it is possible to create more than one normalization rule to be added to the Tenant Dial Plan.

Now that we have created the Tenant Dial Plan, we can grant it either to one specific user, or to a set of users:

Granting to one specific account: Grant-CsTenantDialPlan -PolicyName testA -Identity uk.emsaba@xxx.onmicrosoft.com

Granting the policy to a set of users:

Get-CsOnlineUser -Filter {HostingProvider -eq “sipfed.online.lync.com”} | Grant-CsTenantDialPlan -policyname testA

!Please note that instead of “HostingProvider -eq “sipfed.online.lync.com”” you can use any attribute visible under the get-csonlineuser cmdlet, and that is matching the subset of users you want to have the dial plan assigned. For example, if wanting to grant this new tenant dial plan to all your UK users, you can add the “Usagelocation -eq “UK” filter.

If you wrongfully assigned a Tenant Dial Plan to all your users as advised above, don’t worry, you can remove it with the following command:

Get-CsOnlineUser -Filter {HostingProvider -eq “sipfed.online.lync.com”} | Grant-CsTenantDialPlan -policyname $null

And the result is:

Sabin.

  1. Mkorny

    Very good explanation man!

    Those cmdlets also help a bunch, thanks a lot for this guide.

Leave a Reply

Your email address will not be published. Required fields are marked *