繁体   English   中英

如何将用户分配到 Azure 资源组

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM