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

Bicepparam Use Cases #11895

Closed
Usman0111 opened this issue Sep 20, 2023 · 2 comments
Closed

Bicepparam Use Cases #11895

Usman0111 opened this issue Sep 20, 2023 · 2 comments

Comments

@Usman0111
Copy link
Contributor

Usman0111 commented Sep 20, 2023

Description

This issue contains all the supported/unsupported use cases we can have when using a .bicepparam file to make a deployment with Az CLI. It also contains corresponding build-params Bicep CLI command that would invoked as part of the deployment. Note that build-params command produces in-memory JSON output for .bicep template file, .bicepparam params file and validates any supplemental parameters.

Supported Cases section contains both cases that are currently supported and ones that will be supported in the future. The goal of this issue is to track/discuss these use cases asynchronously.

Supported Cases

Regular usage

Az CLI

az deployment group create \
--parameters 'params.bicepparam' \ 
--template-file 'main.bicep'

Bicep CLI

bicep build-params 'params.bicepparam' \
--bicep-file 'main.bicep'

params.bicepparam

using './main.bicep'

param foo = 'test'

main.bicep

param foo string

Optional template file

CLI

az deployment group create \
--parameters 'params.bicepparam'

Bicep CLI

bicep build-params 'params.bicepparam' 

params.bicepparam

using './main.bicep'

param foo = 'test'

main.bicep

param foo string

Note: If no using declaration is present, we throw an error (from Bicep CLI)

Optional Using

CLI

az deployment group create \ 
--parameters 'params.bicepparam' \
--template-file 'main.bicep'

Bicep CLI

bicep build-params 'params.bicepparam' \
--bicep-file 'main.bicep'

params.bicepparam

param foo = 'test'

main.bicep

param foo string

Note: If no --template value is given, we throw error (from Bicep CLI)

Inline overrides

CLI

az deployment group create \ 
--template-file 'main.bicep'
--parameters 'params.bicepparam' \
--parameters foo='inline' \ 
--parameters bar=1 \ 

Bicep CLI

bicep build-params 'params.bicepparam' \
--bicep-file 'main.bicep'

params.bicepparam

using './main.bicep'

param foo = 'test'
param bar = 0

main.bicep

param foo string
param bar int

Validation Approach

Parameter override values are passed from Az CLI to Bicep CLI using an environment variable. Check the design gist for complete supplemental parameter validation strategy.

Restrictions

Az CLI allows ultimate flexibility when it comes to mix and matching parameter values. That is any type of parameter can provided in any order and latter always overrides the former. However, we have restricted this when a .bicepparam file is used:

1 - The .bicepparam file must always be the first parameter for Az Cli
2 - Only inline parameter overrides allowed (this might be relaxed in future to allow JSON files as well)

Module registry reference

CLI

az deployment group create \ 
--parameters 'params.bicepparam' 

Bicep CLI

bicep build-params 'params.bicepparam' 

params.bicepparam

using 'br:mcr.microsoft.com/bicep/test.bicep'

param foo = 'test'

Unsupported Cases

Multiple bicepparam arguments

CLI

This would add a lot of implementation complexity, and we will instead by providing users the ability to solve this problem via import statements in the future.

az deployment group create \ 
--parameters 'params.bicepparam' \
--parameters 'params2.bicepparam'
Usman0111 added a commit that referenced this issue Oct 2, 2023
…1975)

Enable `build-params` command to use values from a
`BICEP_PARAMETERS_OVERRIDES` environment variable to update the
`.bicepparam` file


This work is to support the Inline overrides [use case for az
cli](#11895)

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/11975)
@adameska
Copy link

adameska commented Nov 9, 2023

'Can not use --parameters argument more than once when using a .bicepparam file.' Is this still in the roadmap to support (currently on 2.53.1 for CLI and 23.1 for bicep)? Not allowing this kind of makes using bicepparam files less than useful if you need to require 1 param to be passed in from a pipeline for example

@anthony-c-martin
Copy link
Member

anthony-c-martin commented Nov 9, 2023

Yes it's still on the roadmap, see #11445 for more information.

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