Transforming phone number formats in Azure AD SSO for Zabbix

gabor-ka 25 Reputation points
2023-08-01T07:33:18.2866667+00:00

Phone numbers in Azure AD are stored like

+36 (20) 123-4567

This Azure AD application is supposed to serve the SSO function for a Zabbix monitoring system, which sends out SMS notifications if something happens. The mobile numbers are gathered from Azure using claims. It does gather the mobile number just fine, but the GSM module only accepts the following number format:

0036201234567

The goal is to pick out only the numbers and no other symbols, regardless of length and country code. I've tried multiple regexreplace patterns. The web interface of Azure AD didn't seem to support variables in regex (most answers by ChatGPT were like that).

The closest i've managed to get was by inserting a blank character into the replacement pattern field (it wouldn't accept being left empty), which looks like returns the numbers mostly fine, but the blank characters stayed and the GSM module couldn't handle it, and I still couldn't figure out a way to prepend 00 before the number. With Join() i couldn't change the order of parameters.

Do you have any suggestion on how to deal with this transformation? Any help would be much appreciated.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Accepted answer
  1. Givary-MSFT 35,626 Reputation points Microsoft Employee Moderator
    2023-08-02T09:56:12.8066667+00:00

    @gabor-ka I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    User's image

    Resolution:

    Resolved by @gabor-ka below are the steps followed

    Regex pattern:

    \+(?'a'\d+) ?\(?-?(?'b'\d+)-?\)? ?(?'c'\d+)-? ?(?'d'\d+)
    

    Replacement pattern:

    ‎‎00{a}{b}{c}{d}
    
    
    

    If you have any other questions, please let me know.
    Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. gabor-ka 25 Reputation points
    2023-08-02T09:08:52.7033333+00:00

    update:

    With the help of a local regex guru, the correct patterns were born. Tested it with numbers from multiple different countries.

    Regex pattern:

    \+(?'a'\d+) ?\(?-?(?'b'\d+)-?\)? ?(?'c'\d+)-? ?(?'d'\d+)
    

    Replacement pattern:

    ‎‎00{a}{b}{c}{d}
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.