Creating Federated Credentials in Parallel on One User-Assigned Managed Identity Fails With 409 Conflict
Overview
Several federated credentials declared on one managed identity deploy in parallel by default, and Azure refuses the overlapping writes with 409 Conflict. Make the writes serial.
At a glance
- Symptom
- A deployment that adds federated identity credentials to a user-assigned managed identity fails, often the first time a template grows from one credential to…
- Likely cause
- Federated identity credentials under one user-assigned managed identity have to be written one at a time, and Resource Manager deploys resources in parallel unless…
- Impact
- The deployment fails and the workloads that need the missing credentials cannot get tokens.
- Verification signal
- The fix is proven when the redeployment completes and every credential in the template appears exactly once on the identity.
- Safe correction
- Make every write under the same identity sequential, then redeploy the unchanged credential definitions.
- Rollback or recovery
- Rolling back means reverting the ordering change and removing only credentials you added in this change.
Azure Resource Manager refuses to write two federated identity credentials under the same user-assigned managed identity at the same moment. When a Bicep file, ARM template, Terraform run or pipeline creates several credentials on one identity at once, Microsoft’s concurrency detection rejects the overlapping writes with HTTP 409 and the error message Conflict, which Microsoft explains as a concurrent write request under the same user-assigned identity being denied. The fix is to create credentials under one parent identity one after another: chain them with dependsOn, deploy a loop with @batchSize(1) in Bicep or "mode": "serial" in ARM, or use the Terraform AzureRM provider 3.40.0 or later. Credentials on different managed identities can still be created in parallel.
Symptom
A deployment that adds federated identity credentials to a user-assigned managed identity fails, often the first time a template grows from one credential to several. A typical case is one credential per Kubernetes service account, per GitHub environment or per branch, all declared in the same file against the same identity. The deployment reports a 409 on one or more Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials resources. A single credential deployed on its own succeeds, which makes the failure look like a flaky platform rather than a template problem.
False Assumption
The natural assumption is that child resources of one parent are independent and safe to create together. Writing the credentials as siblings, each with parent: userAssignedIdentity, looks correct, and nothing in the file hints at a problem. Microsoft documents the opposite for this resource type. By default, all child federated identity credentials in a template are created in parallel, and that parallelism is what triggers the concurrency detection. A valid template is not the same as a deployable one.
Root Cause
Federated identity credentials under one user-assigned managed identity have to be written one at a time, and Resource Manager deploys resources in parallel unless something orders them. Microsoft’s Bicep guidance states that when resources aren’t dependent on each other, Resource Manager deploys them in parallel. A parent property creates a dependency on the identity only, not between the sibling credentials, so they all start together. Microsoft’s considerations page then states that creating multiple federated identity credentials under the same user-assigned managed identity concurrently triggers concurrency detection logic, which causes requests to fail with a 409-conflict HTTP status code. The same applies outside templates: two pipelines, two scripts or a parallel loop writing to the same identity at once can collide.
Terraform users on old providers hit this too. Microsoft notes that Terraform Provider for Azure (Resource Manager) version 3.40.0 creates multiple federated identity credentials sequentially, and that earlier versions can cause pipeline failures when several are created. The provider’s 3.40.0 changelog records the azurerm_federated_identity_credential change that prevents concurrent writes to the parent resource.
Impact
The deployment fails and the workloads that need the missing credentials cannot get tokens. Any credential that lost the race does not exist, so the workload it was meant for cannot exchange its external token for a Microsoft Entra token and cannot reach Azure resources. Credentials that were written before the conflict may already exist, so the identity can be left with a partial set. This is an availability problem, not an exposure: nothing gains extra access. The risk is a rollout that half-works, and a pipeline that someone “fixes” by re-running until it passes.
Diagnosis
Confirm it is a concurrency conflict and not one of the other documented creation errors, which return different codes.
- Read the failed operation in the deployment output. Microsoft documents a concurrency failure as HTTP
409with the error messageConflict, meaning a concurrent write under the same user-assigned identity was denied. - Rule out the look-alikes Microsoft lists.
400Issuer and subject combination already exists for this Managed Identity.is a duplicate, not a race.400Federated identity credentials must have exactly one audience.is a template error.405The request format was unexpected: Support for federated identity credentials not enabled.means the identity’s region doesn’t have them enabled; Microsoft lists Malaysia South as unsupported for user-assigned identities.429is throttling: create or update requests are limited to 0.25 per second per resource. - List what exists now, which also gives you a backup of the identity’s current trust before you change anything:
az identity federated-credential list --identity-name <identity> --resource-group <rg> > fic-backup.json - Compare the names in that output with the template. Credentials missing from the list were the ones refused.
- Check how the template orders the credentials. Siblings with only
parent, a loop with no@batchSizedecorator, or an ARMcopyloop without"mode": "serial"all deploy in parallel. For Terraform, check theazurermprovider version in the lock file.
Correction
Make every write under the same identity sequential, then redeploy the unchanged credential definitions. Precondition: you hold Contributor or Owner on the identity, which Microsoft lists as the role needed to configure federated identity credentials, and you have saved fic-backup.json. Change only the ordering, not the issuer, subject or audience values, so the change cannot alter what the identity trusts.
- Bicep loop: add
@batchSize(1)above the looped credential resource. Microsoft’s Bicep loop guidance says that for sequential deployment you set the batch size to 1. - Separate Bicep resources: give each credential a
dependsOnon the previous one, so they form a chain. Microsoft’s considerations page shows this pattern with three credentials, each depending on the one before. - ARM
copyloop: set"mode": "serial"and"batchSize": 1in thecopyelement. - Terraform: pin the
azurermprovider to 3.40.0 or later. - Scripts and pipelines: run
az identity federated-credential createcalls for one identity in sequence, and stop separate pipelines from writing to the same identity at the same time.
A single CLI call looks like this, with --audiences defaulting to api://AzureADTokenExchange if you omit it:
az identity federated-credential create --name <fic-name> --identity-name <identity> --resource-group <rg> --issuer <issuer-url> --subject <subject> --audiences api://AzureADTokenExchange
Stop and escalate if the redeployment returns 409 again after the change: something else is writing to the identity at the same time.
Validation
The fix is proven when the redeployment completes and every credential in the template appears exactly once on the identity.
- Re-run
az identity federated-credential list --identity-name <identity> --resource-group <rg>and check that each expected name is present with the intended issuer, subject and audience. - Check one credential in detail with
az identity federated-credential show --name <fic-name> --identity-name <identity> --resource-group <rg>. Values must match the external token case-sensitively, and a wrong subject is accepted at creation without error, so a successful deployment alone doesn’t prove the trust works. - Wait a short time before testing a workload. Microsoft documents that a token request soon after configuration can fail with
AADSTS70021: No matching federated identity record found for presented assertion.while the credential propagates. Then run the workload and confirm it gets a token. - Compare the new list with
fic-backup.json. Only the credentials the template meant to add should differ.
Rollback
Rolling back means reverting the ordering change and removing only credentials you added in this change. The ordering change touches no trust, so reverting the template commit is safe on its own. If a credential added in this change is wrong or not wanted, remove only that one with az identity federated-credential delete --name <fic-name> --identity-name <identity> --resource-group <rg>, then compare az identity federated-credential list with fic-backup.json. Never delete a credential that was in the backup: a workload depending on it would lose access to Azure. To recreate a credential removed by mistake, run create again with the issuer, subject and audience recorded in the backup, then wait for propagation.
Prevention
- Treat each user-assigned managed identity as a single writer for federated credentials: one template or pipeline owns its credentials, and that owner writes them serially.
- Default every credential loop to
@batchSize(1)and review new credential resources for adependsOnchain. Credentials on different managed identities can still be created in parallel without restriction. - Pin the Terraform
azurermprovider to 3.40.0 or later. - Remember the hard limit of 20 federated identity credentials per user-assigned managed identity. A template that adds one credential per branch reaches it quickly, and credentials keyed to branches widen trust in ways described in how branch-scoped subjects grant token exchange to every workflow on that branch.
- Don’t reach for wildcard matching to save slots. Standard credentials don’t accept wildcards, and wildcard federated credentials widen a managed identity’s blast radius.
- When a workload still can’t get a token after the deployment succeeds, check the audience next. An audience mismatch blocks the token exchange without a deployment error.
Serial Writes Checklist for One Managed Identity
Before merging a change that adds federated identity credentials, confirm that every write to the same identity is ordered, the deployment shows no 409, and az identity federated-credential list matches the template. If a 409 remains, stop re-running the pipeline and find the second writer: retries hide the race rather than remove it.
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
409ConflictdependsOnWhen to escalate
Validation and rollback are covered in the sections above.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.