Set-CsPhoneNumberAssignment from a powershell function app in Azure

Alistair Young 51 Reputation points
2025-03-28T08:28:57.7666667+00:00

I'd like to run Set-CsPhoneNumberAssignment from a function app in Azure and came across this post which says the "user" needs to be a teams administrator but there isn't a "user" for a function app.

I was going to login using the MS Graph API and an Application Registration with TeamSettings.ReadWrite.All permission and then call Set-CsPhoneNumberAssignment.

Would this work or is it just not possible to automate this powershell command in an Azure function app? Does it need the presence of a physical Teams admin user to run it?

Can the application registration in Entra have the Teams admin role?

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Molly Lu-MSFT 2,586 Reputation points Microsoft External Staff
    2025-03-28T09:21:56.44+00:00

    Hello,

    Thank you for posting in Microsoft Q&A.

    Based on the description, I understand your question is related to Set-CsPhoneNumberAssignment from a powershell function app in Azure.

    You can use an Application Registration in Azure AD (Entra) with the necessary permissions. The TeamsTelephoneNumber.ReadWrite.All permission is required for assigning telephone numbers via the Graph API, which allows the application to manage telephone numbers without needing a physical Teams admin user.

    Also, I found a similar post here:

    https://learn.microsoft.com/en-us/answers/questions/1642411/permissions-needed-to-use-set-csphonenumberassignm

    Ensure that the user logged into MicrosoftTeams has the teams administrator or global administrator role.

    Have a nice day.

    Best Regards,

    Molly

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it


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.