Originally published on KBY Technologies .
When a GitHub Actions job references an environment, GitHub changes the subject ( sub ) claim in the job’s OIDC token. A job without an environment, triggered by a push, sends repo:ORG/REPO:ref:refs/heads/BRANCH . Add environment: production to the same job and it sends repo:ORG/REPO:environment:production instead, on every branch. Microsoft Entra ID only exchanges the token when its issuer and subject exactly match a federated identity credential on the app registration or user-assigned managed identity, so a credential written for the branch stops matching and the azure/login step fails. The fix is to add a second credential with the exact environment subject, let it propagate, and only then merge the workflow change.…