Automation

Bicep what-if: qualify deployment noise before approving an Azure rollout

A production runbook for separating real change, computed values, provider defaults and incomplete analysis in Bicep what-if before approval or rollback.

09 Oct 2026 azurebiceparmwhat-ifiacdevopsautomationsecurityobservabilityrunbookrollbackproduction

A Bicep pull request changes one NSG rule and one tag. The pipeline what-if still reports twelve resources as Modify, several deleted properties and two Ignore results. The team knows the output is noisy, so approval becomes a quick visual pass. When a real subnet change eventually appears in the same output, the control still runs but no longer protects the rollout.

what-if predicts state. It is neither an exhaustive execution plan nor proof that a change is safe. Resource providers can supply default properties, expressions such as reference(), list*(), utcNow() and secure values cannot always be resolved outside deployment, and analysis can short-circuit for a resource or module. The useful response is not to hide every Modify, but to qualify each difference until the decision is explainable.

The running case is an Azure DevOps pipeline deploying a network module at resource-group scope. This runbook must end in one of four outcomes: approve the rollout, fix the template, request a bounded review, or block because the preview is incomplete.

Freeze the change contract

Preserve the commit, parameters, scope, execution identity and tool versions that produced the result. Two previews generated with different parameters or identities are not comparable.

yaml what-if-contract.yml
change_id: CHG-7421
commit: 8f3c2ab
scope: /subscriptions/<subscription-id>/resourceGroups/rg-network-prod
template: infra/network/main.bicep
parameters: infra/network/prod.bicepparam
deployment_mode: Incremental
toolchain:
azure_cli: 2.76.0-or-later
bicep: pinned-by-pipeline
identity:
principal_id: <pipeline-object-id>
validation_level: Provider
expected:
- modify NSG rule allow-monitoring-outbound
- modify tag change-id
forbidden:
- delete or replace subnet
- change route table association
- remove diagnostic settings

Deployment mode matters. In incremental mode, a resource absent from the template is normally ignored; any predicted deletion must therefore be understood in the exact deployment context. Do not reuse a conclusion produced with a different mode, scope or parameter file.

Produce readable output and raw evidence

Keep the human-readable result for review and JSON for automation. With a recent Azure CLI, Provider performs the broadest validation, including write permissions. ProviderNoRbac retains resource-provider validation but only requires read access; Template checks structure and must not be presented as proof that the deployment can succeed.

bash 01-capture-what-if.sh
RG="rg-network-prod"
TEMPLATE="infra/network/main.bicep"
PARAMS="infra/network/prod.bicepparam"

az version --output json > evidence/az-version.json
az bicep version > evidence/bicep-version.txt

az deployment group what-if --resource-group "$RG" --template-file "$TEMPLATE" --parameters "$PARAMS" --validation-level Provider --result-format FullResourcePayloads --no-pretty-print --output json > evidence/what-if.json

Do not use --exclude-change-types Modify to make the job look clean. Filtering NoChange can reduce volume; filtering the class that contains business changes removes the evidence under review. Preserve command diagnostics too: partial analysis is not a quiet success.

Classify before filtering

Modify can describe several very different situations. Review becomes operational when it classifies the cause, not only the symbol.

text what-if-classification.txt
Expected change
Resource ID and property match the pull request
Impact and post-deployment validation are known

Explained noise
Provider default or read-only property
Unresolved expression: reference, list*, utcNow, secure value
Before and after preserve the same operational contract

Out-of-scope drift
Live state differs from code for a reason unrelated to the pull request
Resolve or accept drift in a separate decision

Incomplete analysis
Unexpected Ignore or Unsupported change type
Short-circuit diagnostic on a resource, module or nested deployment
Resource ID or API version cannot be calculated before deployment

Dangerous change
Deletion, logical replacement, lost route, identity or telemetry
Block until cause and rollback are proven

A property shown as deleted because the provider restores a default may be noise. Prove it by comparing live state, the Bicep declaration and a known no-change preview. Team familiarity is not evidence: record the exact JSON path and resource type involved.

Read diagnostics and blind spots

Ignore does not automatically mean no impact. It can represent a live resource outside an incremental template, but it can also appear after nested expansion limits are reached. Short-circuiting likewise occurs when the service cannot calculate a resource ID or API version early enough. Recent CLI versions surface these diagnostics; the pipeline must retain them and give them a distinct state.

Linked templates inside nested deployments and some dependencies on external state can also leave the result incomplete. If a sensitive module disappears from the preview, do not infer NoChange. Run a separate what-if at module scope where possible, make identifiers calculable, or require a manual review of the resource before continuing.

text complete-analysis-gate.txt
Block automatically
A diagnostic says a module or resource was not analyzed
An expected resource is absent from the result
Ignore or Unsupported affects network, identity, data, policy or telemetry
The pipeline does not retain complete diagnostics

Allow bounded review
The blind spot is outside scope and proven by resource ID
A second what-if at child scope covers the resource
The owner explicitly accepts the limitation before deployment

Compare intent, live state and prediction

For every sensitive resource, build a triplet: pull-request intent, live state before change and predicted after state. This prevents existing drift from being mistaken for an effect of the commit.

bash 02-extract-what-if-risks.sh
jq -r '
.properties.changes[]?
| select(.changeType != "NoChange")
| [
    .changeType,
    .resourceId,
    (.delta // [] | map(.path) | join(",")),
    (.unsupportedReason // "")
  ]
| @tsv
' evidence/what-if.json > evidence/changes.tsv

jq -e '
[ .properties.changes[]?
  | select(
      .changeType == "Delete"
      or .changeType == "Unsupported"
      or (.changeType == "Ignore" and (.resourceId | test("subnets|routeTables|roleAssignments|diagnosticSettings")))
    )
] | length == 0
' evidence/what-if.json

Adapt the root path to the response returned by your actual CLI version before turning this into a gate. A parser that reads an empty array because it misunderstood the schema is more dangerous than manual review. Add a negative test with a deliberately forbidden change to prove that the pipeline really fails.

Validate with a canary, not trust in the diff

Even a clean what-if cannot detect a runtime failure inside an extension, an unavailable external dependency or broken application behavior. Prepare validation before approval: DNS resolution, effective route, expected flow, runtime identity and correlated logs according to the affected component.

For the network module in the running case, the canary verifies from a representative workload that the monitoring destination is still reachable, a control destination remains denied and no route-table association changed. Promote only when Azure state and observed behavior tell the same story.

text what-if-decision.txt
Approve
Every change is expected or explained by versioned evidence
No diagnostic leaves a sensitive resource outside analysis
The negative gate test fails as designed
Canary and rollback are ready

Fix or hold
The diff mixes intent and drift
An unresolved expression hides a sensitive property
ProviderNoRbac was used without a separate authorization review
An expected resource is absent from the result

Rollback
Stop rollout on the first failed canary
Redeploy the last approved artifact with frozen parameters
Review the rollback what-if before execution
Replay positive and negative controls, then retain evidence

An IaC rollback is itself a change. Do not blindly rerun an old commit: preview it with archived parameters, confirm that it will not remove a later repair, then execute the same validation matrix.

Conclusion

Noisy what-if output is not a cosmetic problem. Once a team learns to ignore it, a production control becomes ceremonial. The remedy is to preserve execution context, separate proven noise from drift and real change, and treat incomplete analysis as a decision in its own right.

The rollout can proceed when sensitive modifications are explained, blind spots are absent, the negative gate is proven and the canary is ready. Otherwise, the correct pipeline result is to block, reduce scope or roll back with a preview that has itself been reviewed.