从 azure cli 创建服务主体

Create service principal from azure cli

我正在尝试从 azure cli 创建服务主体。

az login --service-principal -u servicePrincipalGuid -p spPassword --tenant tenantGuid

az ad sp create-for-rbac --skip-assignment

如果我分配给服务主体全局管理员,它可以工作,但它不能与应用程序管理一起工作,根据文档,应用程序管理应该足够了。

我想知道 roles/permissions 需要什么才能在没有全局管理员的情况下创建服务主体?

我可以重现你的问题,这真的很奇怪,据我所知,Application administrator 角色应该有效。

命令az ad sp create-for-rbac --skip-assignment创建应用注册成功,但是无法创建对应的服务主体。即使我使用下面的命令测试为应用程序创建服务主体。

az ad sp create --id '<object-id of the app registration>' 

或powershell

New-AzureADServicePrincipal -AppId <object-id of the app registration>

I am wondering what roles/permissions are needed to be able to create a service principal without global administrator?

如果你只想让命令在没有全局管理员的情况下工作,你可以添加 Azure Active Directory GraphApplication.ReadWrite.All 权限,如下所示,然后它将工作。