What does a federated credential for GitHub Actions look like and what is the subject format?
AdvancedConceptEntra ID, RBAC and Identities
Answer
az identity federated-credential create \
--name gh-prod --identity-name id-shop-ci --resource-group rg-shop-ci \
--issuer https://token.actions.githubusercontent.com \
--subject repo:devopsshack/shop:environment:prod \
--audiences api://AzureADTokenExchange
Subject formats GitHub emits:
repo:ORG/REPO:ref:refs/heads/mainfor a branchrepo:ORG/REPO:environment:prodwhen the job uses an environmentrepo:ORG/REPO:pull_requestfor PR workflowsrepo:ORG/REPO:ref:refs/tags/v1.2.3for tags
Subjects must match exactly (newer flexible federated credentials allow wildcard-style claim matching, but exact match is the safe default). Binding to an environment lets GitHub's environment protection rules gate who can get a prod token.
More on Entra ID, RBAC and Identities
What is Microsoft Entra ID and how is it different from on-prem Active Directory?BeginnerWhat is the difference between an app registration and a service principal?BeginnerWhat is a managed identity and what problem does it solve?BeginnerSystem-assigned vs user-assigned managed identity: when do you use each?IntermediateHow does Azure RBAC evaluate access?IntermediateName the core built-in roles and the difference between Owner, Contributor and User Access Administrator.Beginner