Create Parameter Files with BICEP

Introduction

This is a really quick blog to highlight a nice and pretty new feature that has been added to my favourite DSL BICEP.

With the ability to deploy straight from a BICEP file without the need to transpile to JSON. It was noted that there was no feature to create a BICEP parameter file from your script.

You would have to manually create a parameter JSON file, and this could take a while depending on the number of parameters.

Coming from the ARM template world this was not the worst thing as I’ve been doing this forever and a day. However, the ability to have BICEP create the parameters file for you is something people have been requesting for a while.

Well, the wonderful BICEP community have made this happen and as of v0.7.4, the Generate parameters file (generate-params) command was added!

This is great as often your BICEP scripts will contain a large number of parameters and manually creating a parameter file can be quite a time-consuming task (especially for a complicated deployment)

Now we can simply run a single command and BICEP will generate us a nice shiny parameter file in JSON format. We then just need to add the values!

Testing it out

So let’s have a quick look at this new function.

First, we need to ensure we are running on v0.7.4 or higher.

If I run a quick BICEP –version I can see I am running v0.8.9

We can see the syntax for the new command if we run BICEP –help

If I do a quick DIR of my working directory, we can see it does not contain a parameter file of any kind.

I will now run the new BICEP command against my existing mainBuild.bicep file.

bicep generate-params mainBuild.bicep

Now I see it has indeed generated a nice new JSON file for my parameters!

The parameter file will be named as

<bicepfile>.parameters.json

If I view this in VS Code I can see it is a correctly formatted parameter file which can be passed through on my BICEP deployment.

Now currently it doesn’t add any default values nor mark any allowed values. So be aware of this. You may want to add some comments for your own use.

In my case, I can use this auto-generated parameter file in my Azure DevOps Pipeline release and override the parameter values as needed in my deployment. If a default value is to be used the parameter is left blank.

So there we have it, a nice little feature that many people might not know exists.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s