Skip to main content
Azure Workload Identity Federation Without Secrets

Azure Workload Identity Federation Without Secrets

KU
· Founder & Chief Editor
• 7 min read•Updated •25 views

You can remove every client secret from CI by pointing Azure federated credentials at GitHub's OIDC issuer. Here's the exact setup and the claims that trip people up.

Key takeaways

  • Azure workload identity federation replaces client secrets with a federated identity credential that trusts an external OIDC issuer such as GitHub Actions or Kubernetes.
  • Entra ID matches the token's issuer, subject and audience exactly, then issues a short-lived access token.
  • Nothing is stored, so nothing expires or leaks, and each identity allows up to 20 federated credentials.

To authenticate to Azure without secrets, add a federated identity credential to an app registration or user-assigned managed identity that trusts your CI or cluster's OIDC issuer, then log in with azure/login@v3 and only client, tenant and subscription IDs. Entra ID swaps the job's short-lived token for an access token. No client secret exists to leak.

Verified against

azure/login v3.1.0, Azure CLI az identity federated-credential (latest), against the Microsoft Entra workload identity federation overview and considerations pages and the GitHub Actions OpenID Connect docs. Checked October 2026.

Every Azure service principal secret eventually becomes a liability. It ends up in a GitHub Actions secret, a Key Vault, someone's .env, and a Terraform state file all at once. Give it a long expiry and nobody rotates it, so when it finally expires the deploy pipeline dies with AADSTS7000215: Invalid client secret provided. That is the whole problem in one error code: a long-lived string that grants full access, copied to places you stopped tracking.

Federated identity credentials remove the string. Instead of your workload proving who it is with a secret only it should know, it presents a short-lived OIDC token that some trusted issuer already minted for it. Entra ID checks the token's claims against a rule you configured and, if they match, hands back an Azure access token. Nothing to store, nothing to rotate, nothing to leak. This is the Azure flavor of workload identity federation, and the mechanics line up closely with the AWS OIDC equivalent for GitHub Actions if you've done that already.

What a federated credential actually is

You attach a federated credential to either an app registration or a user-assigned managed identity. The credential is not a secret. It is a small object describing which external tokens you trust:

  • issuer: the OIDC issuer URL that signs the incoming token, e.g. https://token.actions.githubusercontent.com for GitHub Actions.
  • subject: the exact sub claim you expect, e.g. repo:acme/payments-api:ref:refs/heads/main.
  • audiences: what the token was minted for. Entra accepts exactly one value here, and the recommended one is api://AzureADTokenExchange.

When a workload calls Entra's token endpoint with a signed OIDC assertion, Entra fetches the issuer's public keys from its .well-known metadata, validates the signature, then compares iss, sub, and aud against your federated credential. All three must match case-sensitively. One character off, and the exchange fails with AADSTS70021: No matching federated identity record found for presented assertion. The same error can appear for a few minutes right after you create the credential, while it propagates, so add a retry before you start debugging claims.

Configuring it with the az CLI

Say you have an app registration for your CI. Grab its object ID and add a federated credential that trusts pushes to main:

code
$ az ad app federated-credential create \
  --id "$APP_OBJECT_ID" \
  --parameters '{
    "name": "gh-payments-main",
    "issuer": "https://token.actions.githubusercontent.com",
    "subject": "repo:acme/payments-api:ref:refs/heads/main",
    "audiences": ["api://AzureADTokenExchange"]
  }'

For a user-assigned managed identity the command is slightly different, but the claim fields are identical:

code
$ az identity federated-credential create \
  --name gh-payments-main \
  --identity-name id-payments-ci \
  --resource-group rg-ci \
  --issuer "https://token.actions.githubusercontent.com" \
  --subject "repo:acme/payments-api:ref:refs/heads/main" \
  --audiences "api://AzureADTokenExchange"

Then give the underlying principal whatever RBAC it needs, scoped as tightly as you can stand:

code
$ az role assignment create \
  --assignee "$APP_CLIENT_ID" \
  --role "Contributor" \
  --scope "/subscriptions/$SUB/resourceGroups/rg-payments"

That is the entire Azure side. No az ad app credential reset, no secret to paste anywhere.

The GitHub Actions side

The workflow needs id-token: write so the runner can request an OIDC token, and it passes the three IDs to azure/login. There is no client-secret.

YAML
# .github/workflows/deploy.yml
permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: azure/login@v3
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

      - run: az group show -n rg-payments -o table

The three values in secrets are just identifiers, not credentials. Leaking them buys an attacker nothing without a token from the trusted issuer bearing the exact subject you allowed.

Token TTL and why it matters

The GitHub OIDC token is minted per job and expires within minutes (the example token in GitHub's docs is valid for five). The Azure access token you exchange it for lasts on the order of an hour, and there is no refresh token in this flow, so once the original assertion has expired you cannot quietly extend the session. This is the point: the credential exists only for the length of one job. There is no standing secret an attacker can find next quarter. The tradeoff is that jobs running longer than the access token need to request a fresh OIDC token and log in again, which for most deploy pipelines never comes up.

Gotchas that cost us an afternoon

The subject is an exact string match, not a prefix or a glob. repo:acme/payments-api:ref:refs/heads/main will reject a push to release, a tag, and every pull request. Environment-scoped runs use repo:acme/payments-api:environment:production instead of the ref: form, so you add a separate federated credential per pattern. You can attach up to 20 per app registration or managed identity, which is plenty for branches and environments but runs out fast if you try one credential per pull request.

If you need pattern matching, the Azure CLI now exposes a preview claims-matching expression (--claims-matching-expression-value) that allows wildcards instead of a fixed subject. It is preview as of October 2026, so we still use exact subjects for production deploy identities.

The audience must match what you configured, normally api://AzureADTokenExchange. GitHub's default OIDC audience is the repository owner's URL (https://github.com/<org>), and azure/login requests api://AzureADTokenExchange by default instead; if you mint the token yourself with core.getIDToken() or curl, set the audience explicitly or Entra rejects it.

Kubernetes workloads follow the same path: the cluster's service account issuer becomes the issuer, and the subject looks like system:serviceaccount:namespace:sa-name. Cross-cloud is similar: Microsoft documents federation from Google Cloud identities, AWS (via IAM outbound identity federation), and SPIFFE/SPIRE, each presenting its own token to the same exchange. Entra-issued tokens themselves cannot be used as the external token.

Questions people ask

What is the difference between a managed identity and workload identity federation?

A managed identity is an Entra identity whose credentials Azure manages for workloads running on Azure resources. Workload identity federation is the mechanism that lets workloads outside Azure, or on Kubernetes, use an identity without a secret by presenting a token from a trusted OIDC issuer. You can attach federated credentials to a user-assigned managed identity or to an app registration, so the two are often used together.

Why do I get AADSTS70021 No matching federated identity record found?

The token's iss, sub, or aud does not exactly match any federated credential on the identity. The usual culprits are a workflow running on a different branch, a tag, a pull request, or a GitHub environment, which each produce a different sub. Decode the token's claims, compare them character by character, and add a credential for that pattern. Newly created credentials can also fail for a few minutes while they propagate.

Do I still need to store AZURE_CLIENT_ID as a secret?

No, but many teams do for tidiness. The client ID, tenant ID, and subscription ID are identifiers, not credentials: without a valid OIDC token whose subject matches a federated credential, they grant nothing. Storing them as repository variables instead of secrets is fine and makes them visible in logs, which helps debugging.

The call we'd make

Federated credentials are the default for any Azure workload that runs somewhere with an OIDC issuer, which is CI, Kubernetes, and most managed compute now. Keep client secrets only for the rare legacy case that genuinely can't present a token, and put a 90-day expiry and an alert on those. Start with your noisiest pipeline, delete its secret the same afternoon, and watch the expiry pages stop. Then lock down the rest of the workflow with our GitHub Actions security hardening checklist, because a secretless login is only as safe as the jobs allowed to request the token.

Sources

Explore topics:SecurityCloud
React
Share this post
Cite this article
Plain text

Kiril Urbonas (2026). Azure Workload Identity Federation Without Secrets. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/azure-workload-identity-federation-without-secrets

Markdown

[Azure Workload Identity Federation Without Secrets](https://www.devopsness.com/blog/azure-workload-identity-federation-without-secrets) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)

KU

Kiril Urbonas

Founder & Chief Editor

586 articles
View all articles by Kiril Urbonas

You might have missed

Evergreen posts worth revisiting.