我正在尝试创建一个新的资源组,一个新的Active Directory用户,然后将该用户作为贡献者分配给资源组。
到目前为止,我已经使用Microsoft.Azure.Management.ResourceManager
成功创建了资源组,并使用Microsoft.Graph
创建了AD用户。我既可以在Azure中看到它们,也可以同时访问它们。
但是,我无法在资源管理器或图形API中清楚地找到如何使用C#将用户分配给资源组的方法。
我可以在这里查看所有其他内容的执行方法> https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal
我认为这是Graph API调用graphClient.DeviceManagement.RoleAssignments但是,从属性中我无法清楚地看到我将资源组详细信息放在何处。
这是我在下面的尝试,但出现错误:该请求不适用于目标租户
var roleAssignment = await graphClient.DeviceManagement.RoleAssignments.Request().AddAsync(new DeviceAndAppManagementRoleAssignment
{
DisplayName = "Test Role",
Members = new List<string>
{
createdUser.Id // GUID of new User
},
ResourceScopes = new List<string>
{
"/subscriptions/04cbb440-e619-4c8f-869f-8dc4d7dd6e42/resourceGroups/NewResourceGroup" // ID of Resource Group
},
RoleDefinition = new RoleDefinition
{
RolePermissions = new List<RolePermission> {
new RolePermission {
ResourceActions = new List<ResourceAction>
{
new ResourceAction {
AllowedResourceActions = new List<string> {"*"},
NotAllowedResourceActions = new List<string>
{
"Microsoft.Authorization/*/Delete",
"Microsoft.Authorization/*/Write",
"Microsoft.Authorization/elevateAccess/Action"
}
}
}
}
}
}
}).ConfigureAwait(false);
有人可以告诉我如何轻松做到这一点或在哪里看?
据我所知,我们应该使用Azure management REST API来管理对Azure资源的访问。
RBAC Graph API用于Intune,要求租户使用Active Intune许可证。它在Intune中管理基于角色的访问。