, Mark Joseph Colibao, home

Fix and maintain GitHub Actions sign-in to Azure with OIDC

What each OIDC sign-in error between GitHub Actions and Azure means and how to fix it, plus what to do after a rename, how to revoke access and keep it safe.

Written 3 min read

Most OIDC failures come down to one string that doesn't match, and the run log tells you which one. The setup is in Passwordless deploys with GitHub Actions and OIDC.

Where a sign-in stops, in the order the run gets there
  1. The job gets a token from GitHubFailed to fetch federated token (no id-token: write)
  2. The login step gets all its IDsNot all values are present
  3. Entra ID finds the app in that tenantAADSTS700016
  4. The app has a federated credentialAADSTS70025
  5. Issuer and subject matchAADSTS70021 · AADSTS700213 · AADSTS7002138 (letter case only)
  6. A role covers the action at that scopeAuthorizationFailed

A job that names an environment sends the environment, not the branch

Run log, subject claimrepo:<owner>/<repo>:environment:production

Credential, subject identifierrepo:<owner>/<repo>:ref:refs/heads/main

→ AADSTS700213

1. Read the run log first

Open the failed run and expand Azure login. Once GitHub has issued a token, the step prints Federated token details: the issuer, the subject claim and the audience. No such lines? The job never got a token (first row below). Otherwise, compare the subject claim with your credential's Subject identifier, character for character.

2. Match the error

What you seeWhyFix
Failed to fetch federated token from GitHub. Please make sure to give write permissions to id-token in the workflow. or Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variableThe job lacks id-token: writeAdd it under the job's permissions:
Not all values are present. Ensure 'client-id' and 'tenant-id' are supplied. or Ensure 'subscription-id' is supplied or 'allow-no-subscriptions' is 'true'.An input arrived empty: a typo in the name, or a secret read with vars. (or the reverse)Match the names and the secrets. or vars. prefix
AADSTS700016 (the application wasn't found in the directory/tenant)Wrong client ID, or the right one sent to the wrong tenantCopy both IDs again from the app's Overview
AADSTS70025: Client application has no configured federated identity credentialsThe app has no federated credential yetAdd one
AADSTS700213: No matching federated identity record found for presented assertion subjectThe subject differs: environment vs branch, name-based vs immutable format, a typoAdd a credential with the exact subject claim from the log
AADSTS7002138 (matches with case-insensitive comparison, but not case-sensitive)Only the letter case differsCopy the subject claim's exact case
AADSTS70021: No matching federated identity record found for presented assertionThe issuer or subject doesn't match, or the credential is only minutes oldCheck the issuer. For a new credential, wait a few minutes and rerun
does not have authorization to perform action ... over scope ... (code: AuthorizationFailed)Signed in, but no role for that action at that scopeAssign the role on that resource, then allow up to 10 minutes

3. After a rename or transfer

The owner and repository names are part of the subject, so a renamed or transferred repository sends a new one. From 15 July 2026, GitHub also moves such a repository to the immutable format. Add a credential for the new subject next to the old one, run the workflow, then delete the old credential. Both can stay while you test.

4. Revoke access

Delete the federated credential and new runs can't get an Azure token (changes take a few minutes to reach every region). Remove the role assignments too.

bash
az ad app federated-credential list --id <client-id> --query "[].{name: name, id: id}" -o table
az ad app federated-credential delete --id <client-id> --federated-credential-id <credential-id>

az role assignment delete --scope <resource-id> \
  --assignee "$(az ad sp show --id <client-id> --query id -o tsv)"

5. Watch the sign-ins

In the Entra admin center, as at least Reports Reader: Entra ID → Monitoring & health → Sign-in logs → Service principal sign-ins. Your app's sign-ins should line up with your deploy runs. One you can't explain is a reason to revoke.

6. Guard who can deploy

Anyone who can push to the trusted branch can deploy. Make that a short list:

  • Protect the branch, so changes arrive through reviewed pull requests.
  • Use an environment with required reviewers. A job that names it waits for approval, and it can't read the environment's secrets until then. Trust the environment subject (:environment:<name>) instead of the branch.
  • Own the workflow files. In .github/CODEOWNERS, add the line below, and turn on Require review from Code Owners in the branch rule. Then no workflow changes without your approval.
  • Pin actions to full commit SHAs, as in the setup note.
text
/.github/workflows/ @<owner>

Sources