How Azure DevOps OIDC Works
Trust Relationship
Based on a pre-configured trust relationship, Entra ID issues a Microsoft Graph access token
Prerequisites
- An Azure DevOps organization and project
- Permissions to create and configure app registrations in Microsoft Entra ID
- Ability to modify Azure DevOps pipelines
- Permissions to create service connections in Azure DevOps
Setup
Create Service Connection
In your Azure DevOps project:
- Go to Project settings > Service connections
- Click New service connection > Azure Resource Manager
- Select Workload Identity federation (manual)
- Fill in:
- Service connection name: e.g., “M365Provider”
- Subscription ID: Your Azure subscription ID
- Tenant ID: Your Microsoft Entra ID tenant ID
- Service principal client ID: The app registration client ID
- Issuer: Your Azure DevOps org URL
- Subject: Service connection identifier
Azure DevOps Pipeline Configuration
Provider Configuration
- Environment Variables (Recommended)
- Terraform Configuration
Required Pipeline Environment Variables
Azure DevOps automatically sets the following environment variables required for OIDC authentication:SYSTEM_ACCESSTOKEN: Token used to authenticate to Azure DevOps servicesSYSTEM_OIDCREQUESTURI: URI to request OIDC tokens
These variables are automatically available to your Terraform commands in most tasks.
Security Best Practices
Pipeline Conditions
Restrict which branches or paths can trigger the pipeline
Approval Gates
Use environments with approval gates for sensitive operations
Conditional Access
Configure additional conditions in Microsoft Entra ID
Least Privilege
Grant only minimum required API permissions
Troubleshooting
Authentication failed
Authentication failed
Verify the federated credential is configured correctly in Entra ID with matching issuer and subject values.
Service connection issues
Service connection issues
Check the service connection configuration in Azure DevOps. Ensure it’s properly configured for workload identity federation.
Permission denied
Permission denied
Ensure you’ve granted admin consent for the required Microsoft Graph permissions in your app registration.
Missing environment variables
Missing environment variables
Verify that
SYSTEM_ACCESSTOKEN and SYSTEM_OIDCREQUESTURI are set and accessible in your pipeline. Some custom tasks may not pass these through automatically.Subject or issuer mismatch
Subject or issuer mismatch
Double-check that the subject and issuer values match between Azure DevOps and the federated credential in Entra ID.
