Context

A Bicep parameter file reads a setting with a default, and a GitHub Actions workflow passes the matching repository or environment variable through to the deploy step.

ttlMinutes: int(readEnvironmentVariable('APP_TTL_MINUTES', '20'))

Insight

readEnvironmentVariable('NAME', 'default') falls back to the default only when the variable does not exist. A workflow line like

env:
APP_TTL_MINUTES: ${{ vars.APP_TTL_MINUTES }}

always defines the variable. When vars.APP_TTL_MINUTES is unset, the variable is an empty string, so Bicep reads '' instead of the default, and int('') fails the deployment.

A deploy from a laptop gets the default (the variable doesn’t exist there), but CI fails. That makes this easy to miss in local testing.

Fix

  1. Put the default in the workflow too:

    APP_TTL_MINUTES: ${{ vars.APP_TTL_MINUTES || '20' }}
  2. Validate the value before the deploy step, so a bad value fails fast with a clear message.

    In PowerShell, use a strict regex, not only [int]::TryParse. TryParse accepts leading and trailing whitespace (' 15 '), which Bicep’s int() may reject:

    Terminal window
    $minutes = 0
    if ($Value -notmatch '^[0-9]{1,2}$' -or
    -not [int]::TryParse($Value, [ref]$minutes) -or
    $minutes -lt 1 -or $minutes -gt 60) {
    throw "APP_TTL_MINUTES must be a whole number from 1 to 60, but is '$Value'."
    }
  3. Optionally, add a CI regression check that the workflow line still carries the || 'default' fallback.