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
- Go to the line BCP028 reports and find the other declaration with the same name.
- Rename one symbol or delete the redundant block.
- 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.bicepHow to prevent it
- Use distinct symbolic names for every declaration in a scope.
- Resolve merge conflicts carefully to avoid duplicated blocks.
- Run
az bicep buildas a CI lint step.
Related guides
Azure Bicep "Error BCP018: expected ... character" in CIFix Azure Bicep "Error BCP018: Expected the ... character at this location" in CI - the .bicep file has a syn…
Azure Bicep "Deployment failed ... InvalidTemplate" in CIFix Azure "Deployment failed ... InvalidTemplate" in CI - the ARM template compiled from Bicep was rejected b…
Azure Bicep "Bicep CLI not found / not installed" in CIFix Azure "Bicep CLI not found. ... az bicep install" in CI - the runner has the Azure CLI but the Bicep comp…