2
votes

The Azure CLI with the Azure DevOps extension has replaced the VSTS CLI. But I can't find any sample on how to connect to Team Foundation Server (TFS) or Azure DevOps Server using Azure CLI with Azure DevOps extension.

I tried to create a PAT on my Azure DevOps Server with all scope permission. Then I use the following command to login:

az devops login --organization https://vm-dev-cgudevops/DefaultCollection --verbose

Here is what I've got:

C:\>az devops login --organization https://vm-dev-cgudevops/DefaultCollection --verbose
Token:
Creating connection with personal access token.
Failed to authenticate using the supplied token.
Suppress exception There are no active accounts.
Suppress exception Please run 'az login' to setup account.
command ran in 25.138 seconds.

The token can't be wrong. I don't know what's going on.

4

4 Answers

2
votes

At present Azure DevOps CLI is not supported for Azure DevOps server. This is fundamentally due to API versioning as Azure DevOps Server runs on a particular version but the CLI client consistently updates to the latest version. Therefore, ideally if you are using the latest version of Azure DevOps Server, then the CLI should work for you as both are using the same API versions.

Have a look at the docs available at - https://docs.microsoft.com/en-us/azure/devops/cli/index?view=azure-devops

2
votes

Azure Cli support login your private TFS currently, see: https://docs.microsoft.com/en-us/azure/devops/cli/log-in-via-pat?view=azure-devops&tabs=windows

  1. Create PAT
  2. Login with PAT, eg. cat PAT.txt|az devops login --organization http://your_tfs_url
1
votes

There is an extension in Azure DevOps that let's you mange the Azure DevOps from Azure CLI.

As mentioned in the extension you have to :

  1. Install the Azure CLI. You must have at least v2.0.49, which you can verify with az --version command.

  2. Add the Azure DevOps Extension az extension add --name azure-devops

  3. Run the az login command.

You can also find a sample for it here.

Read this article if you need more information about how to get started with it.

0
votes

Add /tfs/DefaultCollection to URL. That did the trick for me.