天蓝色图 Users.get(principalID) 抛出 Request_ResourceNotFound
azure-graph Users.get(principalID) throws Request_ResourceNotFound
我正在尝试通过 Node.js 获取资源组的 IAM 列表。返回的列表包含用户 ID 而不是用户名,所以我试图通过用户 ID 获取用户名。
const authorizationManagement = require('azure-arm-authorization');
const GraphkManagementClient = require('azure-graph');
const authorizationClient = new authorizationManagement(credentials, subscriptionId);
const graphClient = new GraphkManagementClient(credentials, tenantId);
let iamList = client.roleAssignments.listForResourceGroup(workspaceName);
for (let i in iamList) {
const user = graphClient.users.get(iamList[i].principalId);
iamList[i].principalId = user;
}
return iamList;
但是行:
const user = graphClient.users.get(iamList[i].principalId);
投掷:
Request_ResourceNotFound: message:"Resource
'b175c95c-e50f-5c46-0b0d-d9f7106d0873' does not exist or one of its
queried reference-property objects are not present."
角色分配本身由以下组成:
- 安全主体 ID(用户、组、服务主体等,无论您要为其分配角色)
- 角色定义 ID(您分配的角色的标识符,例如贡献者、所有者或相关的自定义 RBAC 角色)
- 范围(分配此角色的范围,例如订阅级别或特定资源组)
这个概念在 Microsoft Docs
上有详细和很好的解释
当到达此处讨论的角色分配列表时,响应对象包含 prinicipalId
但不包含 principalType
以指示它是用户、组、服务主体还是 MSI。
因此,查询此主体的一种安全方法是不假定任何特定类型,而只是查找具有该 ID 的对象。
getObjectsByObjectIds
方法 (documentation) available in same package azure-graph
can help with that. Azure AD Graph API being used behind the scene is probably getObjectsByObjectIds
一个侧面节点,值得一提的是这个问题与 密切相关,所以在这里只是引用它以帮助将来阅读本文的任何人的上下文。
我正在尝试通过 Node.js 获取资源组的 IAM 列表。返回的列表包含用户 ID 而不是用户名,所以我试图通过用户 ID 获取用户名。
const authorizationManagement = require('azure-arm-authorization');
const GraphkManagementClient = require('azure-graph');
const authorizationClient = new authorizationManagement(credentials, subscriptionId);
const graphClient = new GraphkManagementClient(credentials, tenantId);
let iamList = client.roleAssignments.listForResourceGroup(workspaceName);
for (let i in iamList) {
const user = graphClient.users.get(iamList[i].principalId);
iamList[i].principalId = user;
}
return iamList;
但是行:
const user = graphClient.users.get(iamList[i].principalId);
投掷:
Request_ResourceNotFound: message:"Resource 'b175c95c-e50f-5c46-0b0d-d9f7106d0873' does not exist or one of its queried reference-property objects are not present."
角色分配本身由以下组成:
- 安全主体 ID(用户、组、服务主体等,无论您要为其分配角色)
- 角色定义 ID(您分配的角色的标识符,例如贡献者、所有者或相关的自定义 RBAC 角色)
- 范围(分配此角色的范围,例如订阅级别或特定资源组)
这个概念在 Microsoft Docs
上有详细和很好的解释当到达此处讨论的角色分配列表时,响应对象包含 prinicipalId
但不包含 principalType
以指示它是用户、组、服务主体还是 MSI。
因此,查询此主体的一种安全方法是不假定任何特定类型,而只是查找具有该 ID 的对象。
getObjectsByObjectIds
方法 (documentation) available in same package azure-graph
can help with that. Azure AD Graph API being used behind the scene is probably getObjectsByObjectIds
一个侧面节点,值得一提的是这个问题与