Skip to content

Conversation

@polatengin
Copy link
Member

@polatengin polatengin commented Oct 30, 2025

Adding an inline() function to .bicepparam files that allows parameter values to be provided at deployment time through the BICEP_PARAMETERS_OVERRIDES environment variable (populated by Azure CLI from command-line arguments).

The function acts as a placeholder during authoring but gets replaced with actual values during compilation.

az deployment sub create --location eastus \
  --template-file main.bicep \
  --parameters @prod.bicepparam sku=Basic location=westus

The CLI passes these overrides (sku=Basic and location=westus) to the Bicep compiler through the BICEP_PARAMETERS_OVERRIDES environment variable as json.

Example usage

param <name> = inline()

The inline() function:

  • Takes zero arguments
  • Returns type any during static analysis
  • Is only valid in parameter assignment expressions in .bicepparam files
  • Acts as a marker/placeholder for runtime replacement

Implementation details;

Direct assignment (Parameter name)
param foo = inline() → uses foo from overrides

Object property (Property name)
param foo = { key1: inline() } → uses key1 from overrides

Array element (Parameter name)
param foo = [inline()] → uses foo from overrides

Nested objects (Property chain)
param foo = { nested: { key: inline() } } → uses nested.key from overrides

Details

  • Implement InlineFunctionValidator to validate inline() usage (allowed only in parameter assignments in .bicepparam; errors for variables, string interpolation, and missing overrides)
  • Add LanguageConstants.InlineKeyword and register inline() function in the system namespace
  • Implement InlineReplacementRewriter in ParamsFileHelper to replace inline() with CLI-provided parameter overrides when building params
  • Hook inline function validation into EmitLimitationCalculator
  • Add diagnostics for BCP442/BCP443/BCP444 with clear error messages
  • Add integration tests covering inline() success and failure scenarios (inline in params, objects, arrays; and invalid usages)
  • Minor whitespace/newline fixes in several test and extension files

Fixes #10454

Checklist

Microsoft Reviewers: Open in CodeFlow

- Implement InlineFunctionValidator to validate inline() usage (allowed only in parameter assignments in .bicepparam; errors for variables, string interpolation, and missing overrides)
- Add LanguageConstants.InlineKeyword and register inline() function in the system namespace
- Implement InlineReplacementRewriter in ParamsFileHelper to replace inline() with CLI-provided parameter overrides when building params
- Hook inline function validation into EmitLimitationCalculator
- Add diagnostics for BCP442/BCP443/BCP444 with clear error messages
- Add integration tests covering inline() success and failure scenarios (inline in params, objects, arrays; and invalid usages)
- Minor whitespace/newline fixes in several test and extension files
@polatengin polatengin self-assigned this Oct 30, 2025
@github-actions
Copy link
Contributor

Test this change out locally with the following install scripts (Action run 18954797366)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 18954797366
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 18954797366"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 18954797366
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 18954797366"

@github-actions
Copy link
Contributor

Dotnet Test Results

    96 files   -     48      96 suites   - 48   42m 26s ⏱️ - 33m 58s
12 532 tests  -      6  12 532 ✅  -      6  0 💤 ±0  0 ❌ ±0 
28 809 runs   - 14 377  28 809 ✅  - 14 377  0 💤 ±0  0 ❌ ±0 

Results for commit eb39686. ± Comparison against base commit 8ea021c.

This pull request removes 1954 and adds 668 tests. Note that renamed tests count towards both.

		nestedProp1: 1
		nestedProp2: 2
		prop1: true
		prop2: false
	1
	2
	\$'")
	prop1: true
	prop2: false
…
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_array_succeeds
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_but_no_override_fails
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_function_succeeds
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_in_object_property_succeeds
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_in_string_interpolation_fails
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_in_variable_fails
Bicep.Cli.IntegrationTests.BuildParamsCommandTests ‑ Build_params_with_inline_type_mismatch_fails
Bicep.Cli.UnitTests.Services.ReplEnvironmentTests ‑ ShouldSubmitBuffer_terminates_at_expected_point ("var foo = {
")
Bicep.Cli.UnitTests.Services.ReplEnvironmentTests ‑ ShouldSubmitBuffer_terminates_at_expected_point ("var multilineString = '''
Line 1
Line 2
Line 3
'''")
Bicep.Cli.UnitTests.Services.ReplEnvironmentTests ‑ ShouldSubmitBuffer_terminates_at_expected_point ("var outRoleAssignments object[] = union(map(
  filter(varMockedEntraGroupIds, item => !contains(item.uniqueName, 'DevOps')),
  group => {
    principalId: group.groupId
    definition: group.roleToAssign
    relativeScope: ''
    principalType: 'Group'
  }
),[
  {
    principalId: '22222222-2222-2222-2222-222222222222'
    definition: 'Reader'
    relativeScope: ''
    principalType: 'ServicePrincipal'
  }
])")
…

@polatengin polatengin marked this pull request as draft November 10, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow parameters to be omitted so they can be supplied at deploy-time

2 participants