Connect Azure DevOps repositories to Catalog with the Konnect API
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
Kong Konnect
If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.
- 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.
-
Set the personal access token as an environment variable:
export KONNECT_TOKEN='YOUR KONNECT TOKEN'Copied!
Konnect roles
You need the Integration Admin role in Konnect to install and authorize Catalog integrations.
Create and configure an Azure account
- You need to configure the following in Azure DevOps:
- An Azure DevOps account.
- An Azure DevOps personal access token (PAT) with
Code:Readpermission.
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.
- Set the personal access token as an environment variable:
export AZUREDEVOPS_PAT='YOUR-AZURE-DEV-OPS-PERSONAL-ACCESS-TOKEN'Copied!
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
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, 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].idin thejqfilter 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"