Interview Prep/GitHub Actions/OIDC & Security Hardening

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.

All GitHub Actions questions Roadmap: GitHub Actions

More on OIDC & Security Hardening