How to Create and Use Service Connections in Azure Pipelines
A service connection stores credentials for an external service so tasks can authenticate without hardcoded secrets.
Create the connection under Project Settings > Service connections, then reference it by name from tasks (e.g. azureSubscription, containerRegistry).
Reference an Azure service connection
The AzureCLI task uses the named connection to authenticate against the subscription.
azure-pipelines.yml
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'prod-azure-conn'
scriptType: bash
scriptLocation: inlineScript
inlineScript: az webapp list -o tableGotchas
- Prefer a workload identity / federated service connection over a long-lived secret-based one.
- Service connections are project-scoped by default; share them across projects explicitly if needed.
- A connection can require approval on first use by a new pipeline - grant access in its security settings.
Related guides
How to Use Variable Groups and Secrets in Azure PipelinesShare variables and secrets across Azure Pipelines with library variable groups - link them, mark secrets, an…
How to Deploy to an Azure Web App from Azure PipelinesDeploy a build to an Azure Web App from Azure Pipelines with AzureWebApp@1 - a service connection, the app na…