Azure Bicep: Non-JSON Parameters available

Hi!
Today morning, I've got great news! Bicep version v0.16.1 has been released with a cool new feature available to the community: Non-JSON parameters
What we're talking about?
For now, almost every bicep deployment comes with a parameters file including all parameters which are needed for the ARM-Deployment.
Here is a short example bicep with an associated JSON parameters file:
# main.bicep:
param Name string
param Location string
param VNET_Range string
param Subnets array
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
name: Name
location: Location
properties: {
addressSpace: {
addressPrefixes: [
VNET_Range
]
}
subnets: Subnets
}
}
# main.parameters.json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"Name": {
"value": ""
},
"Location": {
"value": ""
},
"VNET_Range": {
"value": ""
},
"Subnets": {
"value": [
{
"name": "Subnet-1",
"properties": {
"addressPrefix": ""
}
},
{
"name": "Subnet-2",
"properties": {
"addressPrefix": ""
}
}
]
}
}
}
As you can see, and might know, this can be a bit tricky to work with and nasty to read.
So let's simplify this a little bit...
How does it work?
First of all, we have to enable the new feature. As it is in "experimental" status for now, you'll need to actively enable it via the bicepconfig.json file in the same directory as your bicep project.
Add the following in your bicepconfig.json:
{
"experimentalFeaturesEnabled": {
"paramsFiles": true
}
}
Thereafter you may create a new file in addtion to your main.bicep with the bicepparams ending. (e.g. main.bicepparam)
Syntax
The syntax of these files is very simple as there are actually just two statements for now:
USING:
Declares the associated bicep file of the bicepparam file.
using 'foo.bicep'
You can only use one using statement per bicepparams file.
PARAM:
Declares a parameter in the bicep file.
param Name = "foo"
There must not be param declarations for parameters which aren't included in the associated bicep file.
At the end, the bicepparams file associated to the bicep.main above will look like this:
# main.bicepparams
using 'main.bicep'
param Name = ''
param Location = ''
param VNET_Range = ''
param Subnets = [
{
name: 'Subnet-1'
properties: {
addressPrefix: ''
}
}
{
name: 'Subnet-2'
properties: {
addressPrefix: ''
}
}
]
So much more "bicepy" than Json and clearly :)
Deployment
For now, bicep templates can be only deployed together with a .bicepparams file if you use AzCLI!
Unfortunately there is no implementation in AzPwsh or Visual Studio Code for now.
Make sure you are running the latest AzCLI version on your system:
PS C:\Users\nplc> az upgrade
After upgrading, if you haven't done yet, you can start the deployment by using the usual command:
PS C:</span>Users</span>nplc> # Example Resource Group Deployment
PS C:</span>Users</span>nplc> az deployment group create </span>
-p .</span>main.bicepparam </span>
-f .</span>main.bicep </span>
-g "rg-foo"
Conclusio
For now, bicepparams files are just a way to simplify your parameter-files and raise it's readability significantly.
But looking on the story of this feature, we can expect additional functions in the future, like:
- creating parameter files without link to a bicep-template
- importing other parameter files
- make use of Key Vaults for getting deployment secrets
- (full list: MSFT GitHub)
So stay tuned for the next bicep releases on this feature :)
Please do not use this feature for now in productive scenarios as it is experimental for now!
If you've any concerns, ideas, additional informations.. feel free to use the comment section below.
Cheers!