4
votes

Update

I am trying to create a repository from git bash command line to AzureDevops team platform,

I've been following these instructions:

https://docs.microsoft.com/en-us/azure/devops/repos/git/share-your-code-in-git-cmdline?view=azure-devops

I am having trouble with the prerequisites, I ran the next lines:

az --version                          # version is greater than v2.0.49
az extension add --name azure-devops  # no problem with this line 
az devops login --organization org_url 
PAT                                   # problem arises here.... 

The next line arises after running end line:

Failed to authenticate using the supplied token.

I am creating the PAT by following these instructions:

https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page

Do I have to ask for manager credentials or else what could I do to solve this issue?

3
replace az with az.cmd and retry - P....
do you have the azure CLI tools installed? What happens when you run az --version? - DFord
I already installed Azure CLI it says azure-cli 2.16.0 - AlvaroMartinez
Can you get the existing repos in your DevOps? It means you can run the command az repos list and get the right output. - Charles Xu
Hey @Charles Xu, I can't as az login runs with fail... - AlvaroMartinez

3 Answers

1
votes

From the error message, you probably need to install the Azure CLI. You must have at least v2.0.49, which you can verify with az --version command. Then you can run the az login command to login with your Azure account.

Update

Just follow the article. You can do the steps in your git bash or other terminals:

  1. Download and install Azure CLI and add Azure DevOps extension.
   az extension add --name azure-devops
   az login #login in with your Azure account
   az devops configure --defaults organization=https://dev.azure.com/contoso project=contoso
  1. Create a local Git repo for your code. If your code is already in a local Git repo, you can skip this step.
cd /home/fabrikam/fiber
git init .
git add --all
git commit -m "first commit of my code"
  1. Create a new Git repo in Azure Repos and connect your local repo to the Git repo in Azure Repos using remoteUrl in the response from your creating Git repo :
az repos create --name  mywebapprepos
git remote add origin https://xxx.xxx.com/webapp-test/_git/mywebapprepos

enter image description here

  1. Before pushing your code, you need to login in with your Azure account to authenticate. For me, it will prompt the Windows UI to login in with my account.
git push origin master

enter image description here

1
votes

when I ran az repos create --name mywebapprepos the terminal returns ClientRequestError: 403 FORBIDDEN Operation returned a 403 status code.

According to this error message, I suggest you can try to log in Azure Devops using Full Access PAT(personal access tokens).

enter image description here

Here is a doc about Creating PAT in Azure Devops.

Then when you execute the az devops login , you could use the Full Access PAT as the Identity authentication method.

You can enter PAT in the next line.

Finally, you could try to run the az repos create --name again.

Update:

You can also try to use the following steps:

1.Create a file to save the PAT.

enter image description here

2.You could run the following command:

cat ado.pat | az devops login --organization https://dev.azure.com/orgname

enter image description here

For more detailed information, you could refer to this doc.

1
votes

When you already install Git Bash and Azure CLI in Windows and want to run Azure CLI in git bash, you need to check the environment variable PATH if the path of the CLI is set in it. Like this:

enter image description here

If the CLI path is not in the environment variable PATH, you need to add it yourself like this:

export PATH=CLIPATH:$PATH

Check again and make sure the PATH is right to set. Then you can run the az command like this:

enter image description here

Because the executable program in that path name az.cmd. So if you want to use the command az instead the az.cmd, you need to set the alias for it like this:

enter image description here

When all things is ok, you can run the Azure CLI command as you expect:

enter image description here

Then here is the screenshot of the test on my side for the repos:

enter image description here

Hope all the above will help you solve the issue. And if you have more questions about this issue, please let me know.