Audience Mismatch¶
Symptom¶
The pod has a projected service account token and the issuer looks correct, but Microsoft Entra rejects token exchange or the application reports invalid audience errors.
Possible Causes¶
- The federated identity credential was created with the wrong audience value.
- Automation built a credential template for a different token exchange pattern.
- The application or SDK is not using the intended workload identity flow.
- Operators fixed the issuer and subject but never validated audience alignment.
Diagnosis Steps¶
flowchart TD
A[Projected token exists] --> B[Confirm issuer and subject already match]
B --> C[Inspect federated credential audience]
C --> D[Compare with workload identity token exchange expectation]
D --> E{Audience matches?}
E -->|No| F[Recreate or update federated credential]
E -->|Yes| G[Inspect SDK path and downstream auth] -
Confirm the workload identity basics are already correct before isolating audience.
az aks show \ --resource-group "$RG" \ --name "$CLUSTER_NAME" \ --query "oidcIssuerProfile.issuerUrl" \ --output tsv kubectl get serviceaccount "$SERVICE_ACCOUNT_NAME" \ --namespace "$NAMESPACE" \ --output yamlCommand Purpose az aks showRead the cluster OIDC issuer URL. --resource-groupResource group that contains the AKS cluster. --nameName of the AKS cluster. --querySelects the OIDC issuer URL. --outputOutput format for the result. kubectl get serviceaccountShow the workload service account definition. -
Inspect the federated identity credential definition.
az identity federated-credential show \ --resource-group "$RG" \ --identity-name "$USER_ASSIGNED_IDENTITY_NAME" \ --federated-credential-name "$FEDERATED_CREDENTIAL_NAME" \ --output jsonCommand Purpose az identity federated-credential showShow a federated credential on the identity. --resource-groupResource group that contains the identity. --identity-nameManaged identity that owns the credential. --federated-credential-nameName of the federated credential. --outputOutput format for the result. -
Correlate application logs with token exchange attempts.
-
If the workload reaches Azure but still fails, continue with downstream authorization checks.
Command Purpose az role assignment listList role assignments for the identity. --assigneeObject ID of the identity to inspect. --scopeResource scope to filter assignments. --outputOutput format for the result.
Resolution¶
- Recreate or update the federated identity credential so the audience matches the workload identity token exchange expectation.
- Roll a canary pod and verify fresh token exchange before changing production deployments.
- If the credential matches and failures persist, shift to downstream authorization or SDK-path debugging.
Prevention¶
- Template federated identity credentials from validated automation, not from ad hoc portal entry.
- Validate issuer, subject, and audience together during every workload identity rollout.
- Keep a known-good example for each namespace and service account pattern you standardize.
See Also¶
- Microsoft Entra Workload Identity
- OIDC Issuer Mismatch
- Token Exchange Failure
- RBAC Success but Key Vault Still Fails