Template validation works only on the main deployment

Open
#20,556 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
azure
Domain
cloud, devops

Research direction

The report describes two validation-level issues: child deployments do not inherit the setting, and Az PowerShell deployment commands may omit it from the request. Start by tracing deployment and deployment-stack validation handling for CLI and PowerShell, then compare the request paths with what-if. Done means both reported behaviors are covered by fixes and regression tests; the issue does not name specific files or tests.

Written by the indexing model from the issue text.

Description

AI Triaged investigate Needs: Triage :mag: revisit

Bicep version
Bicep CLI version 0.49.2 (b34271ac51)

Describe the bug
Both Az CLI and Az PS have template validation mode parameter for deployments and deployment stacks. I have never used that parameter before until I have stumbled on a bug in Front Door resource where the validation stops the actual deployment. After using it what I have found is that:

  • What if passes fines and results are generated. Tried on stack, most likely the same for regular deployments what-if.
  • The deployment starts fine where previously it was failing before start.

However when the deployment reaches the problematic resource defined in the template which was previously giving the same validation error is generated. So the deployments started by the main deployment does not inherit that validation level. This makes this option not very usable in real world as 99% of modules I use they generate child deployments.

Additionally there is a bug in new-azResourceGroupDeployment cmdlet where the provided value for -ValidationLevel parameter is not added to the deployment. You can see that behavior using -Debug switch. To compare you can also see Get-AzResourceGroupDeploymentWhatIfResult with -Debug that validation level is added to the Rest call. I have also compared it with az deployment group create --debug and that one also adds the validation level. Most likely this bug is present in all deployment PS commands, may be even on deployment stacks commands as well. I am using Az.Resources 10.2.1.

To summarize there are two issues:

  • Validation level is applied only to the main template deployment and not the child ones. This one applies to both Az CLI and Az PowerShell. For Az PowerShell it is not applied at all. This kind of approach works if you just do what-if results but as soon as an actual deployment is done it fails with the same errors on the child deployments where it was previously failing with Provider (default) mode.
  • For deployment commands like New-azDeployment ValidationLevel parameter value is not applied. The difference can be see by with --debug/-Debug switches on Get-AzDeploymentWhatIfResult/az deployment group create commands.

To Reproduce
Steps to reproduce the behavior:

Provider.

Additional context
Add any other context about the problem here.

Dominant language
Bicep
Stars
3.7k
Forks
833
Avg merge
1d 17h
Merged PRs (30d)
81

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/bicep

All issues in Azure/bicep

Similar issues

More Cloud issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.