首页 > 其他分享 >【Azure 环境】使用 az ad group create 时候遇见 Insufficient privileges to complete the operation

【Azure 环境】使用 az ad group create 时候遇见 Insufficient privileges to complete the operation

时间:2022-12-10 13:05:39浏览次数:71  
标签:group ad -- graph Azure Insufficient type id

问题描述

使用China Azure,通过Azure CLI 创建AAD组报错,提示权限不足 Insufficient privileges to complete the operation

# 使用这个登录:
az login --service-principal --username xxx--password xxx--tenant xxx

#执行 az ad group create
az ad group create --display-name GroupTestAdministrator --mail-nickname azuretest

【Azure 环境】使用 az ad group create 时候遇见 Insufficient privileges to complete the operation_az ad group create

 

问题解决

为了查看更完整的错误信息,在 az ad group create 命令中添加 --debug 参数,用于输出完整的日志信息:

$ az ad group create --debug --display-name GroupTestAdministrator --mail-nickname azuretest  
cli.knack.cli: Command arguments: ['ad', 'group', 'create', '--debug', '--display-name', 'GroupTestAdministrator', '--mail-nickname', 'azuretest']
cli.knack.cli: __init__ debug log:

... ...
urllib3.connectionpool: Starting new HTTPS connection (1): graph.chinacloudapi.cn:443
urllib3.connectionpool: https://graph.chinacloudapi.cn:443 "POST /xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/groups?api-version=1.6 HTTP/1.1" 403 219
msrest.http_logger: Response status: 403
msrest.http_logger: Response headers:
... ...
msrest.exceptions: Insufficient privileges to complete the operation.

查看以上错误日志,最主要的信息是在请求接口 ​https://graph.chinacloudapi.cn​ 时,报错403。而 graph.chinacloudapi.cn 是使用的旧的Azure AD Graph终结点。现在新的为 Microsoft Graph(​https://microsoftgraph.chinacloudapi.cn/​)。

Azure Active Directory (Azure AD) Graph 已弃用,将于近期停用。 作为此弃用路径的一部分,现在已禁用通过Azure 门户向应用注册添加 Azure AD Graph 权限。

为应用注册配置所需的 Azure AD Graph 权限:https://learn.microsoft.com/zh-cn/graph/migrate-azure-ad-graph-configure-permissions

【Azure 环境】使用 az ad group create 时候遇见 Insufficient privileges to complete the operation_Timer Trigger不能多实例运行_02

所以,根据此文的介绍,如要继续使用 az ad group create  创建AD Group,可以修改注册应用的清单权限,来实现赋权。详细步骤见:​​https://learn.microsoft.com/zh-cn/graph/migrate-azure-ad-graph-configure-permissions#option-2-update-the-application-manifest-on-the-azure-portal​​ 

第一步:获取到AAD应用 ​​Windows Azure Active Directory​​​ 或 ​​00000002-0000-0000-c000-000000000000 下的所有Role ID。​

通过Azure CLI指令: az ad sp show --id 00000002-0000-0000-c000-000000000000 , 过滤出结果zhozho能够的 Role ID。

【Azure 环境】使用 az ad group create 时候遇见 Insufficient privileges to complete the operation_az ad group create_03

第二步: 在AAD的注册应用中,通过清单,找到requiredResourceAccess,将 00000002-0000-0000-c000-000000000000 中获取的所有权限,以下表的方式 添加到当前 注册应用的清单中。

"requiredResourceAccess": [
{
"resourceAppId": "00000002-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "a42657d6-7f20-40e3-b6f0-cee03008a62a",
"type": "Scope"
},
{
"id": "5778995a-e1bf-45b8-affa-663a9f3f4d04",
"type": "Scope"
},
{
"id": "78c8a3c8-a07e-4b9e-af1b-b5ccab50a175",
"type": "Scope"
},
{
"id": "6234d376-f627-4f0f-90e0-dff25c5211a3",
"type": "Scope"
},
{
"id": "970d6fa6-214a-4a9b-8513-08fad511e2fd",
"type": "Scope"
},
{
"id": "311a71cc-e848-46a1-bdf8-97ff7156d8e6",
"type": "Scope"
},
{
"id": "c582532d-9d9e-43bd-a97c-2667a28ce295",
"type": "Scope"
},
{
"id": "cba73afc-7f69-4d86-8450-4978e04ecd1a",
"type": "Scope"
},
{
"id": "5778995a-e1bf-45b8-affa-663a9f3f4d04",
"type": "Role"
},
{
"id": "78c8a3c8-a07e-4b9e-af1b-b5ccab50a175",
"type": "Role"
}
]
},
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "8b010b06-ce5b-41ce-bc8b-fa9acdb14371",
"type": "Scope"
}
]
}
],

 

参考资料

更新Azure 门户上的应用程序清单 : ​​https://learn.microsoft.com/zh-cn/graph/migrate-azure-ad-graph-configure-permissions#option-2-update-the-application-manifest-on-the-azure-portal​

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!



标签:group,ad,--,graph,Azure,Insufficient,type,id
From: https://blog.51cto.com/u_13773780/5927475

相关文章