Monday, 25 February 2019

Getting Started with Azure DevOps Command Line

Using command line to work with Azure related resources can be done easily using Azure CLI. Now there is an extension to Azure CLI allowing you to work with Azure DevOps. Let’s have a quick look at how to get it setup and use it for few operations.


Prerequisite
You must have Azure CLI version 2.0.49 or later  installed in your machine. If it is not installed follow the instructions here to get it installed. You can verify the version of Azure CLI installed by executing below command.
az --version

Then execute below command to add Azure DevOps extension to CLI.
az extension add –n azure-devops
Once the extension added you can execute az --version and the installed extensions will be also listed.


Using Azure DevOps Command Line
Login using below command.
az login
Then you can execute Azure DevOps commands providing the organization name and the team project name. For example to list all repos in a team project you can execute below command.
az repos list --org 'https://dev.azure.com/yourorg' -p 'yourproject'

You can set a default organization and project so that execution of commands to be more seamless.
az devops configure -d 'organization=https://dev.azure.com/yourorg 'project=yourproject'
Then you can execute repos list command without org or project arguments.
az repos list

To get help on the commands you can add -h. For example see below commands help.

  • az devops –h
  • az devops configure –h
  • az repos list -h
For further information you can refer to the documentation here.

No comments:

Popular Posts