[英]How to assign a user to an Azure Resource Group
我正在嘗試創建一個新的資源組、一個新的 Active Directory 用戶,然后將該用戶作為貢獻者分配給資源組。
到目前為止,我已經使用了Microsoft.Azure.Management.ResourceManager
成功創建資源組,並與該AD用戶Microsoft.Graph
。 我可以在 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 管理 REST API來管理對Azure 資源的訪問。
RBAC Graph API用於Intune需要租戶的活動 Intune 許可證。 它管理 Intune 中基於角色的訪問。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.