Bitbucket Pipelines OIDC to Azure: "AADSTS70021: No matching federated identity record found for presented assertion"
With OpenID Connect, a Pipelines step gets a signed token and hands it to Microsoft Entra ID, which looks for a federated credential on the app registration (or managed identity) that matches the token. When none matches, the sign-in stops with this:
AADSTS70021: No matching federated identity record found for presented assertion. Assertion Issuer: '...'. Assertion Subject: '...'.
Microsoft's list of Entra error codes in Troubleshoot workload identity service connections (an Azure DevOps page, but the messages come from Entra) shows the message with the issuer and the subject it received, and two narrower ones: AADSTS700211 (no matching record for the presented assertion issuer) and AADSTS700213 (no matching record for the presented assertion subject). For the first, the page says either the issuer URL or the subject does not match.
What Entra compares
From Microsoft's Create a trust relationship between an app and an external identity provider:
- issuer must match the token's
issclaim. Leading or trailing whitespace in the value blocks the exchange. - subject must match the token's
subclaim. It has no fixed format, each identity provider uses its own. If it is wrong, the credential is still created without an error, and the failure shows only when the token is exchanged. - audiences must match the token's
audclaim. The recommended value isapi://AzureADTokenExchange. - Wildcard characters are not supported in any property of a federated credential.
While you sort out the Azure sign-in: Pipeline Inbox for Bitbucket Pipelines, a plugin for JetBrains IDEs, lists the pipelines of every Bitbucket Cloud repository you have in a tool window of the IDE, with the failed step and the command it stopped at.
What a Bitbucket token carries
Atlassian's example token in Deploy on AWS using Bitbucket Pipelines OpenID Connect has these claims (shortened):
{
"sub": "{1de489be-ce6a-42a0-a8c8-eadbf1174ac7}:{bd715740-c970-486b-b68a-b421ec2a1f8b}:{759de0c6-eaee-4eaa-b7a6-c507eec759a7}",
"aud": "ari:cloud:bitbucket::workspace/922e118c-f34f-4226-a897-0e0afbec553d",
"iss": "https://api.bitbucket.org/2.0/workspaces/bbcitest/pipelines-config/identity/oidc",
"repositoryUuid": "{1de489be-ce6a-42a0-a8c8-eadbf1174ac7}",
"stepUuid": "{759de0c6-eaee-4eaa-b7a6-c507eec759a7}"
}
The issuer is the Identity provider URL that the repository's OpenID Connect page under Pipelines shows, with your workspace in it. The sub is {REPOSITORY_UUID}[:{ENVIRONMENT_UUID}]:{STEP_UUID}. The default audience is the workspace value above, not Entra's.
Fix the audience
Atlassian's Integrate Pipelines with resource servers using OIDC lets you set the audiences of the token in the YAML, on a step or under options (up to 10, each up to 150 characters). To match Microsoft's recommended value:
pipelines:
default:
- step:
oidc:
audiences:
- api://AzureADTokenExchange
script:
- echo "token is in $BITBUCKET_STEP_OIDC_TOKEN"
With the audience set, the federated credential's audiences list holds api://AzureADTokenExchange and the issuer holds your Identity provider URL, character for character.
The subject changes with every step
The last part of a Bitbucket sub is the step's UUID, and a step gets a new one each time it runs. A federated credential needs the exact subject, with no wildcard, so the value you would have to enter is not known until the step has started. Atlassian's own tracker says it: in BCLOUD-22038 (choose the format of the sub claim) the report says the claim changes in every build because it includes the step UUID, and the page lists "no known workaround"; BCLOUD-22206 asks for native Azure support for the same reason. Both were in "Gathering Interest" when we checked on November 22, 2026.
Microsoft's flexible federated identity credentials (preview, page updated September 18, 2026), which allow matches with wildcards on the subject, list GitHub, GitLab and Terraform Cloud as the supported issuers. Bitbucket is not on the list. So we found no documented way to make an Entra federated credential match a Bitbucket Pipelines token, and a correct issuer and audience still end in AADSTS700213 on the subject. If a later change on either side adds one, the pages above are where it will show.
Until then: sign in as a service principal
The Azure CLI also signs in with a service principal's client secret or certificate (Sign in with Azure CLI using a service principal). Store the three values as secured variables in the repository settings and use:
image: mcr.microsoft.com/azure-cli
pipelines:
default:
- step:
script:
- az login --service-principal --username "$AZURE_CLIENT_ID" --password "$AZURE_CLIENT_SECRET" --tenant "$AZURE_TENANT_ID"
- az account show
This is a stored secret, which OIDC was meant to avoid; Microsoft's page also covers a certificate instead. If the secret starts with a hyphen, Microsoft's tip is to write --password="$AZURE_CLIENT_SECRET". If a secured variable arrives empty, see A variable is empty.
Bitbucket Pipelines in IntelliJ IDEA
Pipeline Inbox for Bitbucket Pipelines, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of all your Bitbucket Cloud repositories in an IDE tool window, with their steps, the failed step and the command it stopped at, and the step's log as Bitbucket writes it. The az login output with Entra's message is in that log, so you can copy the assertion issuer and subject without opening bitbucket.org. The list, steps and logs are free; running, re-running and stopping pipelines are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
Atlassian, Bitbucket and Bitbucket Pipelines are trademarks of Atlassian; Microsoft, Azure and Entra are trademarks of the Microsoft group of companies; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian, Microsoft or JetBrains.
More: Test results not showing · A variable is empty · "Host key verification failed" (SSH) · "Cannot connect to the Docker daemon" · "authorization denied by plugin pipelines" (Docker) · "Container 'docker' exceeded memory limit." · Pipelines did not run after a push · "Container 'Build' exceeded memory limit." · "Exceeded build time limit of 120 minutes" · The cache is not used · "unexpected system error" · "command not found" · Submodules not cloned · "We couldn't clone the repository" · "No online runner available" · "No space left on device" · "Step exceeded processing limits" · The artifact is missing in the next step · The build passed before and fails now · Build setup takes too long · "You've run out of build minutes" · "Permission denied to update branch" · "You have reached your pull rate limit" (Docker Hub) · "There is an error in your bitbucket-pipelines.yml" · "This pipeline was paused" (deployments) · "Connection refused" to a service (MySQL, PostgreSQL, Redis) · "Container 'build' failed to pull image" · The scheduled pipeline did not run · Git commands that fail in a shallow clone (origin/main, git describe) · Git LFS files that arrive as pointers, and LFS pushes from a step · A step skipped by condition: changesets (includePaths) · Parallel steps that keep running after one fails (fail-fast) · Bitbucket Pipelines plugins for IntelliJ IDEA, compared · "Not authorized to perform sts:AssumeRoleWithWebIdentity" (OIDC to AWS) · "Permission 'iam.serviceAccounts.getAccessToken' denied" OIDC to Google Cloud · "Cannot perform an interactive login from a non TTY device" (docker login) · 日本語