Using Azure DevOps from the Command Line

George

February 13th, 2019

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?

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.

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.

Sign in: Run az login to sign in.

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.

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.

0

George Verghese2019-02-18 14:38:04

|

John MeyerAlready had 2.0.32, per "az -version". Downloaded ...

Hi John,
Sorry to hear that the client version is not being refreshed properly using the download and install method. It did work for me when I tried to move from 2.0.48 to 2.0.52. Are you still facing this issue?
You can run the azure devops extension on cloud shell (https://shell.azure.com) as well.
Thanks,
George Verghese.

0

anonymous2019-02-17 02:28:58

|

John MeyerAlready had 2.0.32, per "az -version". Downloaded ...

This comment has been deleted.

0

Iyyappan Amirthalingam2019-02-14 05:28:54

|

That's Great....!!!!
How about the repo checkin and checkout....?
Please elobrate.
Thanks

0

Martin Woodward2019-02-14 17:35:16

|

Iyyappan AmirthalingamThat's Great....!!!! How about the repo checkin an...

For Git repository operations you should use the Git command line and for TFVC operations the tf command line - we're not planning on duplicating that functionality with-in the Azure command. Was there anything specific you needed with-in the Azure CLI context?

0

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

0

George Verghese2019-02-18 14:50:18

|

Bergmeister, Christoph (MVP)For the previous VSTS CLI, I have a PowerShell mod...