Skip to content
Latchkey

Azure Bicep "Error BCP028: Identifier ... already declared" in CI

BCP028 means a name (a param, var, resource, or module symbol) is declared more than once in the same scope. Bicep cannot resolve which one you mean, so compilation fails before deploy.

What this error means

bicep build or az deployment fails with "Error BCP028: Identifier \"<name>\" is declared multiple times. Remove or rename the duplicates."

Bicep
main.bicep(31,5) : Error BCP028: Identifier "storageAccount" is declared multiple
times. Remove or rename the duplicates.

Common causes

Two declarations share a symbolic name

A param and a resource, or two resources, use the same identifier in the file, which is not allowed.

A merge or copy-paste duplicated a block

A merge conflict resolution or a copied resource block left two declarations with the same name.

How to fix it

Rename or remove the duplicate

  1. Go to the line BCP028 reports and find the other declaration with the same name.
  2. Rename one symbol or delete the redundant block.
  3. Rebuild until BCP028 clears.
main.bicep
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = { ... }
resource storageAccountLogs 'Microsoft.Storage/storageAccounts@2023-01-01' = { ... }

Lint Bicep in CI

Run az bicep build before deploy so duplicate identifiers fail in a fast lint step.

.github/workflows/ci.yml
- run: az bicep build --file main.bicep

How to prevent it

  • Use distinct symbolic names for every declaration in a scope.
  • Resolve merge conflicts carefully to avoid duplicated blocks.
  • Run az bicep build as a CI lint step.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →