Configure OIDC to Azure.
AdvancedConceptOIDC & Security Hardening
Answer
Create an Entra ID app registration (or user-assigned managed identity), add a federated credential with issuer https://token.actions.githubusercontent.com, audience api://AzureADTokenExchange, and subject repo:ORG/REPO:environment:prod. Assign it an Azure RBAC role on the target scope. Then:
permissions:
id-token: write
contents: read
steps:
- uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- run: az aks get-credentials -g rg-prod -n aks-prod
Azure matches the subject exactly (flexible federated credentials with patterns are newer and limited), so you need one federated credential per branch or environment.
More on OIDC & Security Hardening
How does GitHub OIDC work, end to end?IntermediateWhat are the `sub` claim formats, and which do you put in an AWS trust policy?AdvancedConfigure OIDC to AWS: provider, role and workflow.AdvancedConfigure OIDC to GCP.AdvancedWhy pin actions to a full commit SHA, and how do you keep pins updated?IntermediateWhat is script injection, and how do you fix it?Advanced