question

MaciekK-2828 avatar image
1 Vote"
MaciekK-2828 asked singhh-msft commented

DevTstLabs - How to add Repository Azure DevOps (name.visualstudio.com)

Hello,
I am trying to add repository within "Dev Test Lab" in Azure Portal. Configuration and policies > Repositories > Add>repository. I'am trying to connect to Azure Devops repo.

What permissions do I need to have to succesfuly add new repository with token?

I have created personal access token and then i was trying to use this token (manually typing) in Azure but i have only got error "General Error".

Another error that was generated is :
"{
"status": "Failed",
"error": {
"code": "IncorrectClientCredentialOrCollectionUri",
"message": "The URI and/or credentials could not be validated successfully. Please check the URL to ensure it is valid and that the personal access token (PAT) hasn't expired."
}
}"


I think that this problem is related to my persmissions at Azure DevOps. But i dont know what permissions do i need and how to check them.


In my deployment I'am using :


{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"artifactRepoSecurityToken": {
"type": "securestring"
},
"artifactRepositoryDisplayName": {
"type": "string",
"defaultValue": "Repo Name"
},
"artifactRepoUri": {
"type": "string",
"defaultValue": "https://companyname.visualstudio.com/DepartmentName/_git/DevTestLabs"
},
"artifactRepoBranch": {
"type": "string",
"defaultValue": "master"
},
"artifactRepoFolder": {
"type": "string",
"defaultValue": "/Artifacts"
},
"ARMRepoFolder": {
"type": "string",
"defaultValue": "/ARMTemplates"
},
"artifactRepoType": {
"type": "string",
"defaultValue": "VsoGit",
"allowedValues": [
"VsoGit",
"GitHub"
]
}
},
"variables": {},
"resources": [
{
"apiVersion": "2018-10-15-preview",
"type": "Microsoft.DevTestLab/labs/artifactSources",
"name": "[concat(trim(resourceGroup().name), '/',parameters('artifactRepositoryDisplayName'))]",
"location": "[resourceGroup().location]",
"properties": {
"uri": "[parameters('artifactRepoUri')]",
"folderPath": "[parameters('artifactRepoFolder')]",
"armTemplateFolderPath": "[parameters('ARMRepoFolder')]",
"branchRef": "[parameters('artifactRepoBranch')]",
"displayName": "[parameters('artifactRepositoryDisplayName')]",
"securityToken": "[parameters('artifactRepoSecurityToken')]",
"sourceType": "[parameters('artifactRepoType')]",
"status": "Enabled"
}
}
],
"outputs": {
}
}


Any help much appreciated.

azure-devtestlabs
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MaciekK-2828 , thank you for reaching out to us. From the error message above:

 "{
 "status": "Failed",
 "error": {
 "code": "IncorrectClientCredentialOrCollectionUri",
 "message": "The URI and/or credentials could not be validated successfully. Please check the URL to ensure it is valid and that the personal access token (PAT) hasn't expired."
 }
 }"

It looks like your Git Clone URI incorrect OR PAT is expired:

![108258-image.png][1]

Can you please follow this tutorial step by step and try it again?




0 Votes 0 ·
image.png (41.5 KiB)

I have created Personal Access Token based on provided tutorial on Azure DevOps and use it within Azure DevTest Labs > Repositories.
I am getting error: "GeneralError: GeneralError".
108375-repo-error.jpg



I still thinking that the problem is my permisssions. How can i refresh token at Azure DevOps for repo/project.

This repositories within Azure DevTest Labs will be used by many users.

0 Votes 0 ·
repo-error.jpg (43.8 KiB)

@MaciekK-2828 , I was able to successfully add my ADO repo in Azure DTL:

108683-118.png


108620-image.png

Here are the settings which I used for generating PAT token:

108560-119.png

Rest settings are default and please make sure that you also do have at least Read access to the Code/Repo. Let me know if it helps.


0 Votes 0 ·
118.png (30.0 KiB)
image.png (48.3 KiB)
119.png (42.6 KiB)

1 Answer

MaciekK-2828 avatar image
0 Votes"
MaciekK-2828 answered singhh-msft commented

I have done the same with custom defined or even Full access setting for access token and I'm still getting error "GeneralError: GeneralError" within Azure.

I have below permission to the repository that I'am trying to add within azure DevTest Lab resources
108852-devops-repo-permissions.jpg


I have Contributors permissions to the project in Azure DevOps , details attached below:

108768-devops-project-permissions.jpg




So why i cannot connect to the Azure DevOps Repo within Azure DevTest Lab repository?


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MaciekK-2828 , can you try using Artifact Sources - Create Or Update API to perform this operation? Let me know what you see.


0 Votes 0 ·

@MaciekK-2828, just checking in to see if you got a chance to check my response.

0 Votes 0 ·