Thanks to this post, I know how to pass parameters from my yml pipeline through the AzureResourceManagerTemplateDeployment
task to my bicep IaC script. However, my argument arrives as string, even though I specified them in my pipeline.yml as boolean.
This leads to the error 'The provided value for the template parameter 'my_parameter_inside' is not valid. Expected a value of type 'Boolean', but received a value of type 'String'.
My pipeline.yml
parameters:
- name: my_parameter
displayName: Deploy spark pools
type: boolean
default: false
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
csmFile: $(bicep_file_name)
csmParametersFile: $(bicep_parameter_file_name)
...
overrideParameters: -my_parameter_inside ${{ parameters.my_parameter }}
The parameter inside my bicep file:
@description('Enable/Disable something')
param my_parameter_inside bool = true
How can I ensure that the value is passed as a boolean?
I found a bug issue in GitHub in which someone found a workaround for the problem – we have to pass it in lowercase to be recognized as boolean since it would otherwise be passed as False
instead of false
and Bicep doesn’t accept it.
-> ${{ lower(parameters.my_parameter) }}
Working pipeline.yml
parameters:
- name: my_parameter
displayName: Deploy spark pools
type: boolean
default: false
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
csmFile: $(bicep_file_name)
csmParametersFile: $(bicep_parameter_file_name)
...
overrideParameters: -my_parameter_inside ${{ lower(parameters.my_parameter) }}
2