Connect Azure DevOps repositories to Catalog Classic with the Konnect API

Incompatible with
on-prem
Related Documentation
TL;DR

Use the Konnect Integrations API to create and authorize an Azure DevOps integration instance with your organization name and PAT, then map an ingested repository to a Catalog service.

Prerequisites

If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.

  1. The following Konnect items are required to complete this tutorial:
    • Personal access token (PAT): Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
  2. Set the personal access token as an environment variable:

    export KONNECT_TOKEN='YOUR KONNECT TOKEN'

You need the Integration Admin role in Konnect to install and authorize Catalog integrations.

  1. You need to configure the following in Azure DevOps:

    Your PAT can be created with an expiration period of your choice, up to a maximum of one year. Make sure to renew the PAT before it expires to avoid interruptions.

  2. Set the personal access token as an environment variable:
    export AZUREDEVOPS_PAT='YOUR-AZURE-DEV-OPS-PERSONAL-ACCESS-TOKEN'

You’re viewing the Catalog Classic docs. To see the new Catalog experience, see the Catalog documentation.

Configure the Azure DevOps integration

Before you can discover Azure DevOps repositories in Catalog, export your Azure DevOps organization name exactly as it appears in Azure DevOps:

export AZURE_DEVOPS_ORG_NAME="YOUR-ORG-NAME"

Now, configure the integration:

AZUREDEVOPS_INTEGRATION_ID=$(curl -X POST "https://us.api.konghq.com/v1/integration-instances" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "integration_name": "azure-devops",
       "name": "azure-devops",
       "display_name": "Azure DevOps",
       "config": {
         "organization": "'$AZURE_DEVOPS_ORG_NAME'"
       }
     }' | jq -r ".id"
)

Next, authorize the integration with your Azure DevOps PAT:

curl -X POST "https://us.api.konghq.com/v1/integration-instances/$AZUREDEVOPS_INTEGRATION_ID/auth-credential" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "type": "multi_key_auth",
       "config": {
         "headers": [
           {
             "name": "authorization",
             "key": "'$AZUREDEVOPS_PAT'"
           }
         ]
       }
     }'

Once authorized, resources from your Azure DevOps account are discoverable in the UI.

Create a Service in Catalog Classic

Create a service to map to your Azure DevOps resources:

AZUREDEVOPS_SERVICE_ID=$(curl -X POST "https://us.api.konghq.com/v1/catalog-services" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "name": "user-service",
       "display_name": "User Service"
     }' | jq -r ".id"
)

List Azure DevOps resources

Before you map Azure DevOps resources to a service in Catalog Classic, locate the resources that Konnect ingests from Azure DevOps:

AZUREDEVOPS_RESOURCE_ID=$(curl -X GET "https://us.api.konghq.com/v1/resources?filter%5Bintegration.name%5D=azure-devops" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" | jq -r ".data[0].id"
)

Konnect uses the first resource in the list when you run this command. To select a different resource, replace .data[0].id in the jq filter with the index of the resource you want to use or manually specify the resource ID.

Map resources to a service

Now, map the Azure DevOps resource to the service:

curl -X POST "https://us.api.konghq.com/v1/resource-mappings" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "service": "'$AZUREDEVOPS_SERVICE_ID'",
       "resource": "'$AZUREDEVOPS_RESOURCE_ID'"
     }'

Validate the mapping

To confirm that the Azure DevOps resource is now mapped to the intended service, list the service’s mapped resources:

curl -X GET "https://us.api.konghq.com/v1/catalog-services/$AZUREDEVOPS_SERVICE_ID/resources" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!