az ad app permission add - 权限不足,无法完成操作

az ad app permission add - Insufficient privileges to complete the operation

我得到 ERROR: Insufficient privileges to complete the operation. 当 运行 az ad app permission add

我需要授予我的服务主体什么权限才能使它工作?

我给了它 AppRoleAssignment.ReadWrite.All 权限,上面写着:

Allows the app to manage permission grants for application permissions to any API (including Microsoft Graph) and application assignments for any app, on behalf of the signed-in user.

更新:我也给了Application.ReadWrite.All,但是还是报错。

I also gave it Application.ReadWrite.All, but still getting the error.

Application.ReadWrite.All申请权限就够了。我想你在 Microsoft Graph 中给了 Application.ReadWrite.All 权限,它不会起作用。你需要在Azure AD Graph中使用Application.ReadWrite.All,然后它才会起作用。

赋予权限后,稍等片刻,运行命令,returns警告,刷新门户,会发现API权限已添加。

下面是 Azure AD Graph API 的弃用警告。

This application is using Azure AD Graph API, which is on a deprecation path. Starting June 30th, 2020 we will no longer add any new features to Azure AD Graph API. We strongly recommend that you upgrade your application to use Microsoft Graph API instead of Azure AD Graph API to access Azure Active Directory resources

此外,即使未提供相关权限,Microsoft Graph API 似乎也无法正常工作。

由于 Microsoft 图 API 无法使用 Azure CLI AD 应用程序权限,并且 Azure AD 图 API 从 2020 年 4 月开始弃用,这可以通过授予应用程序管理员权限来实现广告应用程序。

从 Azure AD 转到角色和管理员 > 应用程序管理员。

然后添加分配,找到您的客户端应用程序并将其添加到应用程序管理员。

az cli 正在更新以使用 MS Graph API 根据:https://github.com/Azure/azure-cli/issues/12946#issuecomment-737196942

推测此更新将在 AAD Graph API 于 2022 年 6 月 30 日停用之前发生:https://github.com/azure-deprecation/dashboard/issues/178

更新 az cli 后,Application.ReadWrite.All 对 MS Graph API 的权限应该可以工作。