Skip to content

BCP033 thrown when using deployment().location and @allowed on subscription deployments #19278

@jimdigriz

Description

@jimdigriz

Bicep version

$ az bicep version
Bicep CLI version 0.41.2 (3e403ea7c1)

Describe the bug
When using the @allowed decorator in combination with deployment().location it fails with:

$ az bicep build --file test.bicep 
test.bicep(7,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]
test.bicep(7,25) : Error BCP033: Expected a value of type "'eastus2euap' | 'southcentralus'" but the provided value is of type "string". [https://aka.ms/bicep/core-diagnostics#BCP033]

To Reproduce
Contents of test.bicep (minimal reproducible example):

targetScope = 'subscription'

@allowed([
  'southcentralus'
  'eastus2euap'
])
param location string = deployment().location

Replacing deployment().location with a default hardcoded string (eg. southcentralus) or removing the @allowed decorator, the Bicep file becomes valid.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions