【发布时间】:2019-10-17 21:15:42
【问题描述】:
我正在编写一个 python 脚本来预配和配置 Azure 服务。我想在我的脚本中提供一个新的服务主体,但存在权限问题。如果我在终端中运行此命令(在azure login 之后),它将创建服务主体:
az ad sp create-for-rbac --name Testapp
我想实现相同的目标,但在我的 python 脚本中,我使用现有的服务主体进行资源配置。我正在拨打的电话如下:
call("az login --service-principal -u '%s' -p '%s' --tenant '%s'" % (args.client_id, args.client_sec, args.tenant_id), shell=True)
call("az ad sp create-for-rbac --name TestServicePrincipal", shell=True)
参数是现有服务主体的凭据。该服务主体已经是该订阅的OWNER,您可以在此处看到:
在运行我的 python 脚本时,我可以很好地登录(也可以使用这些凭据通过脚本提供一堆其他资源),但是在创建 SP 帐户时会出现权限错误,如您在此处看到的:
synergies git:(master) ✗ python test.py -c 'testcustomer' -l 'eastus' -sid '1234' -cs '1234' -cid '1234' -tid '1234'
[
{
"cloudName": "AzureCloud",
"id": "1234",
"isDefault": true,
"name": "Free Trial",
"state": "Enabled",
"tenantId": "1234",
"user": {
"name": "1234",
"type": "servicePrincipal"
}
}
]
Changing "TestServicePrincipal" to a valid URI of "http://TestServicePrincipal", which is the required format used for service principal names
Insufficient privileges to complete the operation.
我们将不胜感激任何建议!
【问题讨论】:
-
如果您对此有任何其他疑虑,请告诉我。
-
非常感谢@TonyJu 的详细回答,非常感谢您花时间提供帮助!你是对的,我没有授予
Application.ReadWrite.All权限的 SP,添加它确实很有意义,我认为事情会奏效,但是,我仍然遇到完全相同的错误:Insufficient privileges to complete the operation.。我什至创建了一个新的 SP 应用程序并设置了所需的权限,但仍然出现相同的权限问题错误。然后我尝试为 Graph 添加更多权限,但没有区别。不确定还有什么?
标签: azure azure-active-directory service-principal