Replace long-lived Azure service principal secrets with workload identity federation. Use OIDC, narrowly scoped federated credentials, least-privilege RBAC, migration steps, validation, and troubleshooting.
Target Architecture
CI Runner -> OIDC Token -> Microsoft Entra ID -> Azure Access Token -> Azure Resource
Implementation
- Create a dedicated Entra application identity.
- Configure a federated credential restricted to the trusted repository and branch/environment.
- Assign only the Azure RBAC role and resource scope required by the pipeline.
- Configure the CI workflow for OIDC authentication.
- Test trusted and untrusted authentication paths.
- Revoke the old client secret after successful migration.
Example
permissions:
id-token: write
contents: read
steps:
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
Security Validation
Verify that an unauthorized repository or branch cannot authenticate, production access is restricted, old credentials are revoked, and Entra sign-in activity is visible.
Common Mistakes
- Trusting every repository or branch
- Assigning subscription-wide Owner permissions
- Reusing one identity across unrelated pipelines
- Leaving old secrets active
Final Takeaway
Workload identity changes the model from protecting a reusable secret to trusting a specific workload under defined conditions.
Responses (0)
Join the technical conversation or share implementation thoughts.
What are your thoughts?
Sign in to join the technical discussion or share feedback.
There are currently no responses for this story. Be the first to respond.