在中国区使用Azure Developer时,如何启用Microsoft Graph的Get-MgUserAuthenticationPhoneMethod命令?
摘要:问题描述 使用PowerShell Microsoft Graph 命令来获取用户认证的电话信息时,发现 Get-MgUserAuthenticationPhoneMethod 命令在中国区 Azure上不可用。报
问题描述
使用PowerShell Microsoft Graph 命令来获取用户认证的电话信息时,发现Get-MgUserAuthenticationPhoneMethod 命令在中国区 Azure上不可用。报错:Get-MgUserAuthenticationPhoneMethod : Resource not found for the segment 'phoneMethods'.
错误信息:
Get-MgUserAuthenticationPhoneMethod
cmdlet Get-MgUserAuthenticationPhoneMethod at command pipeline position 1
Supply values for the following parameters:
UserId:***@***.partner.onmschina.cn
Get-MgUserAuthenticationPhoneMethod : Resource not found for the segment 'phoneMethods'.
Status: 400 (BadRequest)
ErrorCode: BadRequest
Date: 2025-11-18T12:01:26
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 83*************a78
client-request-id :83*************a78
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"China
North","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"BJ1NEPF00000A4C"}}
Date : Tue, 18 Nov 2025 12:01:26 GMT
At line:1 char:1
+ Get-MgUserAuthenticationPhoneMethod
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ UserId = *****... , Headers = }:<>f__AnonymousType112`10) [Get-MgUserAuthenticationPhoneMethod
_List], Exception
+ FullyQualifiedErrorId : BadRequest,Microsoft.Graph.PowerShell.Cmdlets.GetMgUserAuthenticationPhoneMethod_List
错误截图:
问题解答
这是因为中国区Azure的特殊性导致的,这个命令在正式版的模板代码中( Microsoft.Graph) 还没有被支持,但如果使用Beta版本,就可以成功。
