[Feature Request]Add/Remove User to/from Team
Is your feature request related to a problem? Please describe. We frequently get asked to add/remove users from teams. Currently I've got a Powershell command which is just a wrapper around the REST API.
Please forgive me if I've missed something in the documentation, but I can't see a way to do this currently with the az devops cli.
I'd love to jump in and contribute to this project, I'd just like confirmation that this is a valid Feature Request/a good idea.
Describe the solution you'd like Something like this?
az devops team add-member --team --user (The name or id of the user to add)
az devops team remove-member --team --user (The name or id of the user to add)
EDIT: Having read #319 I guess this should be
az devops team member add
az devops team member remove
And list-member should then be
az devops member list
as originally proposed
Additional context
I'd also like to be able to pipe the output of
az devops user show --user
to the command
@ishitam8 : is this already supported?
HI @teejam2 ,
This is not yet released, but the functionality would be coming up in next release (i.e version 0.5.0) Every team would be considered as a group as well , and you can manage teams the same way you manage groups . Please find the details of command structure in this issue #471
Add/remove member functionality is supported as a part of group management commands where you can create/update/list and delete groups as well.
Currently, you can list members for the team anyway with this command az devops team list-member --team <team_name>/<team_ID> But for rest of the operations you will have to use Group related commands.
Check az devops team list-member --help for more details.
What do you mean by following? I'd also like to be able to pipe the output of az devops user show --user to the command Could you please tell me what is the scenario you are trying to solve here?
Thanks for clarifying @ishitam8 , I did see that issue but I didn't think that teams would fall inside the same scope as security groups. IMO that's not intuitive since those are presented to me as separate entities in the UI and by the REST API.
re: piping a user to the add-user command, that would be an intuitive way for me to do it, as I probably won't know a user's ID, but would know their email address. A scenario would be to loop over a list of email addresses, get each user, then add them to a Project Team.
Thanks @teejam2 for your feedback. I know its not very intuitive when it comes to CLI for managing teams within groups, but UI gives the capability to manage teams from security page itself as well. Hence we thought it would be appropriate to keep the teams along with group management in CLI also.
Scenario : Adding members to team If the users you are trying to add to the team (by looping over a list of email IDs) are already added in the organization , you can directly add them to team via using group commands and corresponding Email IDs
The commands would look something like this [to add a user to team 'MYPROJECT TEAM'] (I am assuming you have defaults configured for your org and project)
az devops user add --email-id <EMAIL_ID> --license-type <LICENSE> [If user is not already a part of the org]
az devops security group list
[You can get group descriptor for 'MYPROJECT TEAM' by using jmespath query along with this command]
Lets say descriptor is vssgp.Uy0xLTXXXXXXXXXXXXXX
To add a user to this team:
az devops security group membership add --group-id vssgp.Uy0xLTXXXXXXXXXXXXXX --member-id <EMAIL_ID>
Does this make sense to you ? You shall be able to use group commands in next release. Please let me know if this would solve your scenario or not.
@ishitam8 That sounds ideal!
@teejam2 , Group commands are available in latest release. Hence, closing this. Please use the security group commands for your scenario and let us know if you have any feedback.
[You can get group descriptor for 'MYPROJECT TEAM' by using jmespath query along with this command]
Took me a few to figure out how to use this in a bash script by setting a variable. Here's an example:
groupDescriptor="$(az devops security group list --project MYPROJECT --output json --query "graphGroups[?displayName == 'MYPROJECT Team'].descriptor | [0]" -o tsv)"
Then echo $groupDescriptor or use it elsewhere in your script. It contains the descriptor e.g. vssgp.Uy0xLTXXXXXXXXXXXXXX.... To add a user to the project's group:
az devops security group membership add --group-id $groupDescriptor --member-id <EMAIL_ID>
These commands, running from the Azure CLI pipeline task at least, had trouble figuring out if I was logged in or not, and to fix it I had to specify the --org parameter.
Thank you for your feedback.
Took me a few to figure out how to use this in a bash script by setting a variable. Here's an example:
Yeah, that is the reason we have kept the group list command at the project level, so only groups filtered by that project is visible. This is necessary to list all groups. I would make sure to add a couple of example or update help text to make this experience better.
I would suggest if you are automating these commands, please use --org variable with every command.
This is not specific to group commands, you would have to pass --org in every command if there is no default configured.
Alternatively, you can configure your default org and/or project by following command
az devops configure -d organization=<YOUR_ORG_URL> project=YOUR_PROJECT_NAME
Took me a few to figure out how to use this in a bash script by setting a variable. Here's an example:
I don't know if you'll read this, but thank you for sharing that tidbit! You've made my life easier!
At least for now, because I understand the Graph stuff is going away, so I'll need to re-learn how to do it in the new setup.