【Azure 环境】执行 az ad user show –id 报错 Insufficient privileges to complete the operation

问题描述

本地环境中,执行 az ad user show -id 时候,报错 insufficient privileges to complete the operation !

 

问题解答

此报错说明,登录Azure (az login) 时,所使用的账号权限不足所导致的。

AZ AD USER SHOW -ID 命令是获取全部用户信息的命令,根据文档,执行这个命令需要User.Read.All的权限。

如果登录所使用的账号 ( 注册应用 Service Principl ) 中已经被赋予了足够的权限,但重新登陆后,报错依旧。则可以考虑先清空本地缓存后重试。

 

清空本地缓存的办法:

1) 清空该目录 ( C:\Users\<username>\.Azure ) 下的文件

2) 登录AAD,并使用 --debug 输出日志

az login --service-principal --username xxx --password "xxx" --tenant xxx --allow-no-subscriptions --debug

3)执行 user show 命令

az ad user show --id xxx --debug

 

此外,也可以检查az 的版本,查看登录账户的Access Token以供分析

az version

获取ms graph token,并使用 https://jwt.ms 中解析

az account get-access-token --resource-type ms-graph --debug

 

参考资料

permissions for az ad user show:https://github.com/Azure/azure-cli/issues/11029

Get a user:https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http

 

posted @   路边两盏灯  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结
历史上的今天:
2024-03-04 【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
2022-03-04 【Azure 应用服务】如何查看App Service Java堆栈JVM相关的参数默认配置值?
2021-03-04 【Azure 服务总线】Azure Service Bus中私信(DLQ - Dead Letter Queue)如何快速清理
点击右上角即可分享
微信分享提示