Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"using" statement is mandatory when deploying template with .bicepparam file #11097

Closed
mischavandenburg opened this issue Jun 30, 2023 · 2 comments

Comments

@mischavandenburg
Copy link

mischavandenburg commented Jun 30, 2023

Bicep version
Bicep CLI version 0.18.4 (1620479)

Describe the bug

When using the new .bicepparam files we can establish the relation with the template with the "using" statement. This improves development and editing experience.

However, when the statement is left out, and the the parameter file is linked to the template by deploying with the Azure CLI, it will throw an error stating that it is obligatory:

"Error BCP261: A using declaration must be present in this parameters file"

To Reproduce
Steps to reproduce the behavior:

I have a simple main.bicep to deploy a key vault, and a keyvault.bicepparam containing:

using 'main.bicep'

param keyVaultName = 'mischacoffeetest109'
param keyVaultSku = 'standard'

I validate it using the Azure CLI:

az deployment group validate -f main.bicep -p keyvault.bicepparam -g coffee

Validating this deployment succeeds.

However, when I use the parameter file as follows, I get an error:

//using 'main.bicep'

param keyVaultName = 'mischacoffeetest109'
param keyVaultSku = 'standard'
(ins)$ az deployment group validate -f main.bicep -p keyvault.bicepparam -g coffee
/Users/mischa/Repos/github.com/mischavandenburg/lab/bicep/keyvault-parameters/keyvault.bicepparam(1,1) : Error BCP261: A using declaration must be present in this parameters file.

I've also tried this with what-if and az deployment group create, and I get the same errors.

Additional context

It seems from #399 that the original intention of the "using" statement was for validation only, based on the heading "Linking to a Bicep file for better validation"

Having this relationship established inside a static textfile is acceptable during development and gives the editor great capabilities in validation. However, it becomes very cumbersome and redundant during deployments especially when the param-file is in a workload repo and the template-file is in a generic/utility/library repo. During deployments this relationship is already clear because of the --template-file keyvault.bicep --parameters keyvault.bicepparam cli arguments. Having a static path included in the param file means all parameter files should be adjusted when the location of 1 template file is changed which violates the "seperation of concerns" principle.

If the general idea is to remove the --template-file parameter when using a .bicepparam file, I could understand the choice of making "using x.bicep" required, but for the above mentioned practical reason of not wanting a static link in many similar paramfiles, I would greatly prefer to have the "using" statement is optional.

Otherwise I am super stoked about the new .bicepparam files and they are great improvement to my life as a Cloud Engineer!

I'm also willing to pick up this issue myself if someone would be willing to guide me a bit. I can code in Go & Python but C# is outside my current skillset unfortunately. I would love to contribute.

@ghost ghost added the Needs: Triage 🔍 label Jun 30, 2023
@slavizh
Copy link
Contributor

slavizh commented Jul 2, 2023

Somehow duplicate to #10333

@alex-frankel
Copy link
Collaborator

Agreed - closing as dup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants