当前位置: 首页 > news >正文

【Azure Developer】解决在中国区 Microsoft Graph 命令Get-MgUserAuthenticationPhoneMethod 不可用的问题

问题描述

使用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

错误截图:

image

 

问题解答

这是因为中国区Azure的特殊性导致的,这个命令在正式版的模板代码中( Microsoft.Graph) 还没有被支持,但如果使用Beta版本,就可以成功。

注意:在使用Beta版本命令前,需要卸载 Microsoft.Graph, 安装Microsoft.Graph.Beta 后,重新登录中国区Azure,方可使用Beta命令:Get-MgBetaUserAuthenticationPhoneMethod

 

需要执行指令为:

## 卸载以及重新安装Beta版

uninstall-Module Microsoft.Graph

install-Module Microsoft.Graph.Beta -Repository PSGallery -Force

 

## 断开与Graph的连接

disconnect-graph

## 重新登录Graph

connect-MgGraph -Scopes "User.ReadWrite.All", "UserAuthenticationMethod.ReadWrite.All", "UserAuthenticationMethod.ReadWrite" -ClientId "your entra id registered application client id" -Environment China -TenantID "your tenant id"

## 获取用户Phone Method信息

Get-MgBetaUserAuthenticationPhoneMethod 

 

最终效果为:

image

所以,解决这个问题的替代方案为:使用Beta版本的指令。同理,如果需要使用REST API来获取信息,可以PowerShell的命令中加上 -debug 参数,查看这些命令输出日志中所发起的API请求,即可反推出正确的API Endpoint!

 

 

参考资料

管理 Microsoft Entra 多重身份验证的身份验证方法 :https://learn.microsoft.com/zh-cn/entra/identity/authentication/howto-mfa-userdevicesettings#manage-methods-using-powershell

 

http://www.jsqmd.com/news/43916/

相关文章:

  • 基于Redis的滑动窗口限流-Golang实现
  • 查看laya已经加载的资源
  • ESP32 + LVGL 开发笔记(一):点亮屏幕
  • 聊聊deepseek对latex的辅助
  • 【LVGL】图片部件
  • linux c makefile
  • 基于自适应遗传算法风光场景生成的电动汽车并网优化调度【IEEE33节点】(Matlab代码建立)
  • 10大 spring源码设计模式 (图解+秒懂+史上最全)
  • 实用指南:《中国电力产业数字化》深度解析与前沿展望(下)——中国电力数字化转型路线图:SPARK 融合平台的设计与落地方案
  • High Frequency Active Auroral Research Program(HAARP)部分摘取
  • CF813E Army Creation
  • Mac 怎么安装 PyCharm 2020.1.dmg?超简单教程(附安装包)
  • TypeScript-安装安装
  • C# 蓝牙远程控制应用:从零达成移动设备与硬件的无线交互
  • 铭记旧友
  • AI热潮下的冷思考:从估值泡沫到就业现实
  • 杨辉三角形
  • update 锁表了: 执行一个update 表被锁了,原因是什么?
  • 标题:鸿蒙Next音频开发新篇章:深入解析Audio Kit(音频服务) - 实践
  • 春秋云境Apache OFBiz 目录遍历致代码执行漏洞 CVE-2024-36104
  • 在 Ubuntu 20.04 上安装 gcc/g++ 11,并使用 update-alternatives 管理多个版本。
  • Doris学习笔记
  • 人工智能之编程进阶 Python高级:第一章 栈和队列
  • Spring AI Alibaba 项目源码学习(十一)-Hook
  • linux c ini
  • Spring AI Alibaba 项目源码学习(十二)-完结:Tool
  • linux busybox
  • DS trick record 2
  • 详细介绍:MonkeyCode:开源AI编程助手的技术实践与应用价值
  • ftp,sftp,scp,tftp几种简单对比,以及python实现ftp功能