Skip to content

Service Connections

ado-aw pipelines use Azure Resource Manager (ARM) service connections to mint Azure DevOps-scoped tokens at runtime. These tokens grant the pipeline controlled access to ADO APIs — separately for the agent (read) and the executor (write).

The compiled pipeline uses the AzureCLI@2 task to call az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 — this mints a short-lived ADO token scoped to the service connection’s identity. This keeps credentials short-lived and auditable, and avoids storing long-lived PATs.

ConnectionUsed byPurpose
Write (required for safe outputs)Stage 3 — SafeOutputs executorCreate PRs, work items, wiki pages, etc.
Read (optional)Stage 1 — AgentQuery ADO APIs (work items, repos, builds)

This is the minimum required connection. It powers Stage 3 safe-output execution.

  1. Go to your Azure DevOps Project → Project Settings → Service connections

  2. Click New service connection → Azure Resource Manager

  3. Choose your authentication method:

    The simplest option — Azure DevOps creates the app registration and credentials for you.

    • Select Service principal (automatic)
    • Choose an Azure subscription (the identity needs at least Reader on the subscription — this is only used for az login, not for ADO operations)
    • Scope to a resource group if preferred
    • Name the connection (e.g. ado-aw-write) — this is the value you’ll use in permissions.write
    • Click Save

    Azure DevOps creates an Entra ID app registration and configures everything automatically.

  4. Grant ADO permissions to the service principal. The identity behind the connection needs permission to perform write operations in Azure DevOps:

    • Go to Azure DevOps Organization Settings → Users
    • Add the service principal (search by its app registration name)
    • Set access level to Basic
    • Add it to a project-level group with the permissions your safe outputs need — Contributors is sufficient for most use cases (PRs, work items, branches, tags, wiki pages)
  5. Reference it in your agent front matter:

    permissions:
    write: ado-aw-write # ← name of the service connection you created

Create the read service connection (optional)

Section titled “Create the read service connection (optional)”

If your agent needs to query Azure DevOps APIs (e.g. read work items, list PRs, fetch build results), create a second connection with read-only ADO permissions.

Follow the same steps as above, but:

  • Name the connection ado-aw-read (or similar)
  • In ADO, grant the service principal Readers group access (or a custom group with only read permissions)

Then reference both in your agent file:

permissions:
read: ado-aw-read
write: ado-aw-write
ConfigurationAgent can read ADO?Safe outputs can write?
Both read + write
Only read
Only write
Neither (default)

On the first run, Azure DevOps will prompt you to authorize the pipeline to use the service connections. You can also pre-authorize:

  1. In the service connection’s settings, go to Security
  2. Under Pipeline permissions, click + and add your ado-aw pipeline (or grant access to all pipelines in the project)

To confirm your service connection can mint ADO tokens, create a test pipeline:

trigger: none
pool:
vmImage: ubuntu-latest
steps:
- task: AzureCLI@2
displayName: "Test ADO token mint"
inputs:
azureSubscription: 'ado-aw-write' # your connection name
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
TOKEN=$(az account get-access-token \
--resource 499b84ac-1321-427f-aa17-267ca6975798 \
--query accessToken -o tsv)
if [ -n "$TOKEN" ]; then
echo "✅ Successfully minted ADO token (${#TOKEN} chars)"
else
echo "❌ Failed to mint ADO token"
exit 1
fi

If this pipeline succeeds, your connection is correctly configured for ado-aw.


SymptomLikely cause
AzureCLI@2 fails with “service connection not found”The pipeline isn’t authorized to use the connection — check pipeline permissions in the connection’s Security tab
Token mints but safe outputs return 401/403The service principal doesn’t have sufficient ADO permissions — verify its group membership in ADO Organization Settings → Users
”AADSTS700024: Client assertion is not within its valid time range”Federated credential issuer/subject mismatch — regenerate in the App Registration
Compilation error: “require write access to ADO, but no write service connection is configured”Your agent uses write-requiring safe outputs but is missing permissions.write in front matter