| title | BCP420 |
|---|---|
| description | The scope couldn't be resolved at compile time because the supplied expression is ambiguous or too complex. Scoping expressions must be reducible to a specific kind of scope without knowledge of parameter values. |
| ms.topic | reference |
| ms.custom | devx-track-bicep |
| ms.date | 12/22/2025 |
In Bicep, every resource or module must have a known deployment scope at compile time. The scope must be statically determinable. If the scope depends on a parameter, a variable, or an expression that can't be evaluated during compilation, Bicep throws BCP420.
The scope couldn't be resolved at compile time because the supplied expression is ambiguous or too complex. Scoping expressions must be reducible to a specific kind of scope without knowledge of parameter values.
Error
The following code triggers BCP420 because the scope property uses a conditional expression that depends on the runtime value of the targetResourceGroupName parameter. Bicep requires that scope expressions resolve to a specific scope at compile time, without relying on parameter values or dynamic logic. Since the compiler can't determine the scope without evaluating targetResourceGroupName, it throws BCP420.
param targetResourceGroupName string = 'my-target-rg'
param storageAccountName string = 'mystorageacct'
param location string = 'eastus'
module storageModule './module.bicep' = {
name: 'deployStorage'
scope: empty(targetResourceGroupName) ? resourceGroup() : resourceGroup(targetResourceGroupName)
params: {
storageAccountName: storageAccountName
location: location
}
}For more information about Bicep diagnostics, see Bicep core diagnostics.