Bicep Parameter Files

A parameter file stores the values for one deployment in a separate file. The Bicep template stays unchanged while each environment brings its own values. Typing a dozen values on the command line invites typos, and a parameter file removes that risk.

Consider a cake recipe. The recipe stays the same, while a small card lists quantities for a birthday party or a family dinner. The template is the recipe, and each parameter file is a card.

One Template, Many Environments

                    main.bicep  (the recipe)
                         │
        ┌────────────────┼─────────────────┐
        ▼                ▼                 ▼
  dev.bicepparam   test.bicepparam   prod.bicepparam
  sku: B1          sku: B1           sku: P1v3
  count: 1         count: 1          count: 3
        │                │                 │
        ▼                ▼                 ▼
   Dev resources    Test resources    Prod resources

The Template

// main.bicep
param appName string
param sku string
param instanceCount int
param location string = resourceGroup().location

resource plan 'Microsoft.Web/serverfarms@2023-01-01' = {
  name: 'asp-${appName}'
  location: location
  sku: {
    name: sku
    capacity: instanceCount
  }
}

A .bicepparam File

The using line links the parameter file to its template. Each param line supplies one value.

// prod.bicepparam
using './main.bicep'

param appName = 'shop-prod'
param sku = 'P1v3'
param instanceCount = 3

The editor checks each value against the template. A missing required parameter or a wrong type shows an error while typing.

Deploy with a Parameter File

az deployment group create \
  --resource-group rg-shop-prod \
  --parameters prod.bicepparam

The same command with dev.bicepparam builds the development setup. Only the file name changes.

Expressions in Parameter Files

Parameter files accept simple expressions and functions. Reading an environment variable keeps values such as build numbers out of the file.

using './main.bicep'

param appName = 'shop-${readEnvironmentVariable('ENV_NAME', 'dev')}'
param sku = 'B1'
param instanceCount = 1

The second argument of readEnvironmentVariable supplies a fallback when the variable does not exist.

The JSON Parameter File

Older projects use JSON parameter files. Both formats work with the same templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": { "value": "shop-prod" },
    "sku": { "value": "P1v3" },
    "instanceCount": { "value": 3 }
  }
}

The .bicepparam format reads easier and offers type checking, so new work benefits from it.

Good Habits

Name Files by Environment

Names such as dev.bicepparam and prod.bicepparam show the purpose at a glance.

Keep Secrets Out

Parameter files usually live in source control. Passwords, keys, and tokens belong in Azure Key Vault or in pipeline secret storage, never in the file.

Store Files Beside the Template

A single folder holding the template and its parameter files makes reviews simple. Reviewers compare the dev and prod files and spot differences immediately.

Defaults Versus Parameter Files

Default values inside the template cover settings that rarely change, such as the storage type or the location. Parameter files carry values that differ between environments, such as server size and instance count. Splitting the settings this way keeps the template short and keeps each parameter file focused on what makes its environment unique. A reviewer reading a pull request sees exactly which values changed for production.

Testing a Parameter File

Run a what-if preview with the parameter file before a real deployment. The preview lists every resource Azure would create or change, so a wrong value shows up before it causes trouble.

Summary

Parameter files separate values from logic. A .bicepparam file starts with a using line and lists one param per value. One template serves every environment through its own file, and deployment commands only change the file name.