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 →
- 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"]}' - Update the workflow:
permissions: id-token: write, contents: readandazure/login@v2withclient-id,tenant-id,subscription-idonly - Run the workflow and confirm
az account showworks - 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.
More on Identity, Access and Governance
A new developer joins and needs to deploy to the dev resource group only. How do you give access?BeginnerAuditors ask "who has Owner on production, and why?" How do you answer and fix it?IntermediateA VM application needs to read blobs from one container. How do you set up access without keys?IntermediateTeams keep creating resources in random regions and without tags. How do you stop it?BeginnerA contractor needs temporary read access to logs for two weeks. How do you handle it?BeginnerYou need to let an app team create their own role assignments for their identities, without giving them Owner.Advanced