Interview Prep/Azure/Identity, Access and Governance

Your GitHub Actions workflow uses a client secret stored in a repo secret. Security wants it gone. What do you do?

BeginnerScenarioIdentity, Access and Governance
Answer

Situation read → A long-lived secret in CI is the most common Azure credential leak. Replace it with workload identity federation.

What I'd do →

  1. Add a federated credential to the existing app registration (or switch to a user-assigned identity):
    az ad app federated-credential create --id <appId> --parameters '{
      "name":"gh-main","issuer":"https://token.actions.githubusercontent.com",
      "subject":"repo:devopsshack/shop:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}'
    
  2. Update the workflow: permissions: id-token: write, contents: read and azure/login@v2 with client-id, tenant-id, subscription-id only
  3. Run the workflow and confirm az account show works
  4. Delete the client secret: az ad app credential delete --id <appId> --key-id <keyId> and remove the repo secret

Why → Federated tokens live minutes, are bound to a repo and branch or environment, and there is nothing to rotate or leak.

Interview tip → Mention binding the subject to a protected GitHub environment for prod.

Azure All Azure questions Roadmap: Azure core services

More on Identity, Access and Governance