Using Azure DevOps from the Command Line

George Verghese

George

We talk with customers who love the command line. Donovan Brown maintains the community VSTeam command for folks that love PowerShell, but we’re pleased to announce that we now have a public preview of Azure DevOps extension for the Azure CLI which is available cross platform.

The extension allows you to experience Azure DevOps from the command line, bringing the capability to manage Azure DevOps right to your fingertips! This allows you to work in a streamlined task/command oriented manner without having to worry about the GUI flows, providing you a faster and flexible interaction canvas.

This looks exciting, how do I get started?

  1. Install Azure CLI: Follow the instructions available on Microsoft Docs to set up Azure CLI in your environment. At a minimum, your Azure CLI version must be 2.0.49. You can use az -version to validate.
  2. Add the Azure DevOps extension: az extension add --name azure-devops You can use either az extension list or az extension show --name azure-devops to confirm the installation.
  3. Sign in: Run az login to sign in.
  4. Configure defaults: Although you can provide the organization and project for each command, we recommend you set these as defaults in configuration for seamless commanding. az devops configure --defaults organization=https://dev.azure.com/contoso project=ContosoWebApp

Now you are all good to go!

Example

Let us look at an example where the Azure DevOps extension can be used to view and trigger a build for an Azure Pipeline.

  1. Log into your Azure Account Login to Azure CLI
  2. Configure defaults Configure defaults
  3. View the list of builds List all builds
  4. Queue a build Queue a build

For the documentation and for more information on the commands currently supported, take a look at the Azure DevOps extension documentation. If you have any changes you’d like or suggestions for features then we’d love your feedback in our Azure DevOps extension GitHub repo – we’re taking PR’s!

George Verghese
George Verghese

Senior Program Manager, Azure DevOps

Follow George   

11 Comments
Niels Swimberghe
Niels Swimberghe 2019-07-03 12:41:45
So this is to extend the Azure cli with Azure DevOps services, what about on-premises Azure DevOps Server?Is there CLI's available for that?
Nikos Vovos
Nikos Vovos 2019-07-02 07:43:54
Nice and convenient. The only thing that I cannot find is how I can deploy a specific stage.I can make a stage (after-release triggered) and from the CLI to create a release but I do not want this.I would like to deploy to a stage which is manually triggered. Does CLI support this?Furthermore, can I set up a Schedule-release trigger using the CLI?Thank you for the post
Avatar
Rodion Sychev 2019-04-24 05:25:19
I'm using azure-cli 2.0.59"az -version" gives an error while "az --version" works as expected
Avatar
John Meyer 2019-02-16 18:14:18
Already had 2.0.32, per "az -version". Downloaded & installed 2.0.58, rebooted, and... "az -version" errors for missing _command_package and displays the using text. The extension command also errors, adding --debug claims I'm still running 2.0.32 although Programs & Features shows 2.0.58... uninstalled, rebooted, verified that Programs & Features doesn't show Azure CLI installed, tried the commands anyway, got the same results, so 2.0.32 is opbviously somewhere on my system, although I can't find any evidence of it other than that running "az" doesn't give a command not found error.
Iyyappan Amirthalingam
Iyyappan Amirthalingam 2019-02-14 05:28:54
That's Great....!!!! How about the repo checkin and checkout....? Please elobrate. Thanks    
Avatar
Bergmeister, Christoph (MVP) 2019-02-14 01:23:41
For the previous VSTS CLI, I have a PowerShell module called posh-vsts-cli that integrates it into PowerShell via tab completion and returning rich objects. I plan to update it to support the new CLI. Watch the repo of the original module for an announcement:https://github.com/bergmeister/posh-vsts-cli