何时...
az ad sp create-for-rbac -n 'test' --sdk-auth
的东西创建新的服务主体... 然后 ...
!az role assignment list --assignee 'serv_princ_obj_id'
列出新的服务主体属性[
{
"canDelegate": null,
"id": "/subscriptions/redact/providers/Microsoft.Authorization/roleAssignments/redact",
"name": "redact",
"principalId": "redact",
"principalName": "http://test",
"principalType": "ServicePrincipal",
"roleDefinitionId": "/subscriptions/redact/providers/Microsoft.Authorization/roleDefinitions/redact",
"roleDefinitionName": "Contributor",
"scope": "/subscriptions/redact",
"type": "Microsoft.Authorization/roleAssignments"
}
]
... 或分配系统分配的托管身份 ...
az functionapp identity assign -g MyResourceGroup -n MyUniqueApp
)... 通常有一个--scope
选项。我在任何地方都找不到这些范围和说明的列表。
正在寻找类似az account list-locations --query [].displayName
的东西,但是用[].scopes
代替。
有人知道在哪里可以找到这些东西吗?
答案 0 :(得分:1)
在“ az ad sp”命令中,“-scopes”参数指的是您要将服务原理附加到的目标资源(带有订阅,资源组详细信息)。
例如: az ad sp create-for-rbac -n“ test”-角色贡献者 --scopes / subscriptions / {SubID} / resourceGroups / {ResourceGroupName}
因此,列出作用域意味着您需要列出有权访问的订阅中的资源。下面的命令可能会有所帮助:
az资源列表 -订阅 -资源组
请参阅this天青cli页面。
答案 1 :(得分:0)
谢谢@ megh-6789。为了扩展您的答案,在运行az resource list --subscription $sub_id
之后,我可以看到id
的资源与我正在寻找的--scopes
语法相匹配。
示例:
{
"id": "/subscriptions/redact/resourceGroups/redact/providers/Microsoft.Maps/accounts/redact",
"identity": null,
"kind": null,
"location": "global",
"managedBy": null,
"name": "redact",
"plan": null,
"properties": null,
"resourceGroup": "redact",
"sku": {
"capacity": null,
"family": null,
"model": null,
"name": "s1",
"size": null,
"tier": "Standard"
},
"tags": null,
"type": "Microsoft.Maps/accounts"
}
似乎可以将scope
设置为订阅,资源组或资源级别。