【问题标题】:How to add team administrator using azure CLI?如何使用 azure CLI 添加团队管理员?
【发布时间】:2020-01-20 18:50:58
【问题描述】:

我在 ADO 中创建了一个自定义的团队组,并尝试使用 azure cli 添加团队管理员,但没有找到任何相关的 az devops 命令!有没有办法使用azure cli添加团队管理员?

【问题讨论】:

    标签: azure-devops azure-cli azure-devops-extensions azure-cli2


    【解决方案1】:

    您可以通过为用户分配团队安全命名空间的正确权限来做到这一点。这是一个将两个用户作为管理员添加到新团队的示例。

    $myOrg = "https://dev.azure.com/myOrg/"
    $newTeam = "My New Team"
    $newAdmin = "user1@me.com"
    $newAdmin2 = "user2@me.com"
    $myProject = "My Project"
    
    az login
    
    $team = az devops team create --name $newTeam --org $myOrg --project $myProject | ConvertFrom-Json
    
    $user = az devops user show --user $newAdmin  --organization $myOrg | ConvertFrom-Json
    az devops security group membership add --group-id $team.identity.subjectDescriptor --member-id $user.user.descriptor --org $myOrg
    az devops security permission update --id "5a27515b-ccd7-42c9-84f1-54c998f03866" --subject $user.user.principalName --token "$($team.projectId)\$($team.id)" --allow-bit 31  --org $myOrg
    
    $user = az devops user show --user $newAdmin2 --organization $myOrg | ConvertFrom-Json
    az devops security group membership add --group-id $team.identity.subjectDescriptor --member-id $user.user.descriptor --org $myOrg
    az devops security permission update --id "5a27515b-ccd7-42c9-84f1-54c998f03866" --subject $user.user.principalName --token "$($team.projectId)\$($team.id)" --allow-bit 31  --org $myOrg
    

    【讨论】:

    • 添加 --alow-bit 31 效果很好!没想到它会起作用,但谢谢!
    【解决方案2】:

    有没有办法使用azure cli添加团队管理员?

    不,无法使用Azure CLI 添加团队管理员。

    在 CLI 中使用以下命令,您将看到当前可用的所有命令,其中不包括“添加团队管理员”:

    PS C:\Users\***> az devops team -h
    
    Group
        az devops team : Manage teams.
    
    Commands:
        create      : Create a team.
        delete      : Delete a team.
        list        : List all teams in a project.
        list-member : List members of a team.
        show        : Show team details.
        update      : Update a team's name and/or description.
    

    添加团队管理员最方便的方式应该是through the UI

    此外,您可以使用Rest Api来实现这一点,您可以参考How to add Team administrator through Azure DevOps REST API?按照建议的解决方案中的步骤,您将能够添加特定的团队管理员。(请求正文应为{"teamId":"{teamId}","newUsersJson":"[\"{userId}\"]","existingUsersJson":"[]"}. ,解决方案似乎有这个小错误。)

    【讨论】:

    • 有计划添加这个功能吗?
    猜你喜欢
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    • 2020-06-09
    • 2020-07-21
    • 2020-09-06
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多