We're Hiring!
Take the next step in your career and work on diverse technology projects with cross-functional teams.
LEARN MORE
Mountain West Farm Bureau Insurance
office workers empowered by business technology solutions
BLOG
03
27
2024
4.5.2024

Utilizing Bicep Parameter Files with ALZ-Bicep

Last updated:
3.27.2024
4.5.2024

The ALZ-Bicep repo on GitHub provides a proven and repeatable approach to deploying Azure Landing Zones using Azure Bicep Infrastructure as Code (IaC) via either GitHub or Azure DevOps pipelines. If you are unfamiliar with this repo, I encourage you to use it for your Azure Landing Zone deployments.

At Lunavi, we deploy dozens of Azure Landing Zones for customers every year, and that brings up one of the limitations of the pipeline deployments: they use the JSON (JavaScript Object Notation) format for parameter files. While Bicep is an extension of the ARM (Azure Resource Manager)templates used traditionally to deploy Azure resources, it still uses JSON for its parameter files.

Here is an example of a JSON parameter file from the ALZ-Bicep GitHub repo.

In the example above, every JSON parameter file used for an Azure Landing Zone deployment requires updates to these parameters and more. In the default implementation, this requires modification of up to 11 JSON parameter files. When you have customers with different needs and deployments in different Azure regions, you can see the complexity of updating 11 JSON parameter files with every new Azure Landing Zone.

Beginning with Bicepv0.18.4 and newer, you now have the option to use Bicep files for parameters instead of JSON. This opens a whole world of opportunities to streamline your deployments. Now let’s take a look at what you can do with Bicep parameter files.

Taking the example of the JSON parameter file above, and converting it to a Bicep template, we can take advantage of additional features available in Bicep files. The ALZ-Bicep deployment pipelines already use a common environment file (.env) to set some global environment variables for use within the pipelines. We will extend to provide the additional common parameters we need in our Bicep parameter files.

The using statement in the Bicep parameter file ties the Bicep parameter file to a Bicep template, or it can also be associated with an ARM JSON template, Bicep modules, or template specs. This is also useful later on as you will see.

The next thing you will notice is a parameter being declared and the default value being a Bicep function called readEnvironmentVariable. This allows us to declare parameters from environment variables. So, by utilizing the .env environment file mentioned earlier, we can declare all our common parameters in one .env file, instead of multiple JSON parameter files as before.

The original environment file, as delivered with the bootstrapped version of ALZ-Bicep, has some useful variables already set for use by the deployment pipelines.

But there are many more variables we can set globally. Here is an example from a recent full Azure Landing Zone deployment.

Here is one more example of a Bicep parameter file used to set default policy assignments.

And just for reference, here is what the default policy assignment JSON parameter file looks like.

Finally, here is one more example of how simple the parameter files become when using Bicep parameter files. This is the parameter file used to set custom role definitions.

I mentioned the using statement earlier, it helps in other ways as well. Previously, when using a JSON parameter file, you had to reference both the template file and the parameter file. Now, you only need to reference the parameter file, as the reference is inferred with the using statement above!

I’ve created a GitHub repo with the ALZ-Bicep JSON parameter files converted to Bicep parameter files, including pipeline.yml files for deploying from Azure DevOps. Hopefully this helps you achieve more efficient Azure deployments.

Recent Blog Posts

lunavi logo alternate white and yellow
5.20.2024
05
.
20
.
2024
From Silos to Synergy: Microsoft Fabric's Role in Optimizing Data Use Across Enterprises

In today’s digital environment, the role of data as a strategic asset is undeniable. Organizations across the globe generate vast amounts of data, but unfortunately, a significant portion of this potential goldmine remains unused. With Microsoft Fabric, you can make the most of your data and eliminate organizational silos!

Learn more
lunavi logo alternate white and yellow
4.5.2024
03
.
27
.
2024
Utilizing Bicep Parameter Files with ALZ-Bicep

Ready to achieve more efficient Azure Deployments? You can use Bicep parameters instead of JSON which opens new opportunities for deployment. Let Lunavi expert, Joe Thompson, show you how.

Learn more
lunavi logo alternate white and yellow
3.26.2024
03
.
04
.
2024
Anticipating Surges in Cyber Attacks and Bolstering Your InfoSec Defenses in 2024

Learn how to navigate 2024 with the right InfoSec defenses to protect your organization against a rising number of cyber attacks.

Learn more