Skip to main content

How to set up Azure Repos

Updated over 2 weeks ago

Accessing source code in Azure Repos is what allows Foundational to accurately determine data lineage and analyze pending and historical pull requests.

This setup should take about 10 minutes.

On-premise agent supported

In order to configure Azure Repos, you will need the following steps:

  1. Configure a Personal Access Token

  2. Configure Foundational Azure Repos Connector

  3. Configure Web Hooks

These steps are detailed below.

Step #1: Configure a Personal Access Token (PAT)

Create a Personal Access Token (PAT) in your Azure account by following the steps in this link: Create PAT.

  1. Choose a specific organization.

  2. One year expiration is recommended.

  3. Choose the following scopes when configuring the PAT:

    1. Code : Read & Write

    2. Code : Status

    3. Project and Team : Read

    4. Pull Request Threads : Read & Write

    5. User Profiles : Read

    6. Identity : Read

Consider creating a special Azure user for Foundational: The owner of this PAT will appear as an author of all Foundational Pull Request comments.

Step #2: Configure Azure Repos Connector

  1. Go to Foundational's Integrations page.

  2. Click on Azure Repos.

  3. Click Add new Azure Repos connection.

  4. Enter Organization Name as it appears in Azure Repos UI.

  5. Enter the Personal Access Token.

  6. Choose a strong password and enter it under Webhook Password.

    1. (Store it, you will need it in the future)

  7. Click Save.

Step #3: Configure Web Hooks

The Web Hooks notify Foundational on certain events, such as new merge requests, new commits to existing merge requests, etc.

Manual configuration

  1. Create five Web Hooks for each of the projects that you would like to integrate with Foundational by following these steps, or by running the script below.

  2. Choose those triggers for different Web Hooks:

    1. Code pushed

    2. Pull request created

    3. Pull request updated

    4. Pull request merge attempted

    5. Repository created

  3. Use the this value for URL (ORG_NAME is an Organization Name as it appears in Azure Repos UI):
    ​https://hooks.foundational.io/api/v1/azure_repos_webhook?id_=ORG_NAME

  4. Use this value for basic authentication username: foundational-webhook

  5. Use the Webhook Password from above for basic authentication password

Scripted configuration

If you would like to automate Web Hooks creation, please use this script and substitute the values in double curly braces:

  1. The executing user must be in Project Collection Administrators group for this command to succeed.

  2. Run this script five times per project which you would like to onboard with the following values for {{EVENT_TYPE}} :

    1. git.repo.created

    2. git.push

    3. git.pullrequest.created

    4. git.pullrequest.updated

    5. git.pullrequest.merged

curl -u :{{PERSONAL_ACCESS_TOKEN}} --request POST \
-H "Content-Type: application/json" \
--data '{
"publisherId": "tfs",
"eventType": "{{EVENT_TYPE}}",
"resourceVersion": "1.0",
"consumerId": "webHooks",
"consumerActionId": "httpRequest",
"publisherInputs": {
"projectId": "{{PROJECT_UUID}}"
},
"consumerInputs": {
"url": "https://hooks.foundational.io/api/v1/azure_repos_webhook?id_={{ORG_NAME}}",
"basicAuthUsername": "foundational-webhook",
"basicAuthPassword": "{{WEBHOOK_PASSWORD}}",
"resourceDetailsToSend": "all"
}
}' \
"https://dev.azure.com/{{ORG_NAME}}/_apis/hooks/subscriptions?api-version=7.1"

Did this answer your question?