Azure / Azure/bicep

@Allowed decorator forces case sensitivity even though ARM doesn't require it

Open
#2,489 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
bicep --version
Bicep CLI version 0.3.255 (589f0375df)

**Describe the bug**
Adding an @allowed syntax decorator forces a parameter to be case sensitive even though the ARM parameter is not.

**To Reproduce**
A simple repo is a parameter that takes valid Azure regions

``` bicep
@allowed([
'EastUS'
'EastUS2'
'CentralUS'
'NorthCentralUS'
'SouthCentralUS'
'WestCentralUS'
'WestUS'
'WestUS2'
'CanadaEast'
'CanadaCentral'
'BrazilSouth'
'NorthEurope'
'WestEurope'
'FranceCentral'
'FranceSouth'
'UKWest'
'UKSouth'
'GermanyCentral'
'GermanyNortheast'
'GermanyNorth'
'GermanyWestCentral'
'SwitzerlandNorth'
'SwitzerlandWest'
'NorwayEast'
'NorwayWest'
'SoutheastAsia'
'EastAsia'
'AustraliaEast'
'AustraliaSoutheast'
'AustraliaCentral'
'AustraliaCentral2'
'ChinaEast'
'ChinaNorth'
'ChinaEast2'
'ChinaNorth2'
'CentralIndia'
'WestIndia'
'SouthIndia'
'JapanEast'
'JapanWest'
'KoreaCentral'
'KoreaSouth'
'SouthAfricaWest'
'SouthAfricaNorth'
'UAECentral'
'UAENorth'
])
param targetResourceRegion string
````

You cannot pass in "eastus" even though its a perfectly valid region

**Additional context**
I do realize this is a crappy way to code this, but this is directly from Microsft docs: https://docs.microsoft.com/en-us/azure/azure-monitor/alerts/resource-manager-alerts-metric#template-file-6

Possible solutions
- Make the @Allowed decorator case insensitive
- Add a decorator @CaseInsensitive
- Add decorator types @AzureRegion - which may not work (run time vs compile time when looking at different AzureEnvironments (i.e. Azure vs AzureUSGovernment)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the Bicep CLI and the provided @allowed region parameter example, then compare its validation with ARM's case-insensitive behavior. Review the implementation and tests for the @allowed decorator; done means a value such as "eastus" is accepted while invalid regions remain rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.