A request from our Telecoms team asked if we could sync the phone numbers of newly ported users from Teams to AD as part of a scheduled task. The command worked without issue with the Teams Admin role enabled but when running the command Get-CsOnlineUser as an Azure app we got the following error.
Get-CsOnlineUser: Access Denied.
The fix is to give the application the Skype for Business admin role in Azure/Entra ID. The app can be added to the role via the GUI, just copy the App ID and then search for that when adding a role member.

↑ Above we have both an Azure app and a Managed Identity added to the Skype for Business admin role.