我试图创建一个新的资源组,一个新的Active Directory用户,然后将该用户作为贡献者分配给资源组。
到目前为止,我已经使用Microsoft.Azure.Management.ResourceManager
成功创建了资源组,并使用了Microsoft.Graph
创建了AD用户。我既可以在Azure中看到它们,也可以同时访问它们。
但是,我无法在资源管理器或Graph 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);
有人可以告诉我如何做到这一点或在哪里看吗?
答案 0 :(得分:0)
据我所知,我们应该使用Azure management REST API来管理对 Azure资源的访问。
RBAC Graph API用于 Intune ,要求租户具有活动的Intune许可证。它管理Intune中基于角色的访问。