Bicep and the cost of statelessness
Why I expected more from Microsoft's infrastructure tooling
In this article
- The appeal of having no state file
- Deployment is only part of the lifecycle
- A small change still submits the whole template
- A phased migration exposes the remaining friction
- The baseline makes the trade-off visible
- Terraform had already demonstrated the value
- The caveats still shape the experience
- A familiar disappointment

My frustration with Bicep is the accumulation of caveats. Behaviour that feels straightforward in Terraform turns into another restriction to understand, another special case to discover, or another feature to add to the deployment workflow.
Microsoft could have done better in the design. Infrastructure as code was already an established practice when Bicep arrived. Terraform provided a working reference for managing infrastructure throughout its lifecycle. Microsoft had the opportunity to learn from that experience.
Deployment stacks make this criticism more interesting, because they address important gaps. They also make the value of retained state difficult to dismiss.
The appeal of having no state file
Microsoft’s comparison of Bicep and Terraform describes the distinction clearly: Terraform stores state; Bicep relies on incremental deployment without maintaining its own state file.
I understand the appeal. A state file needs somewhere to live. Teams need to secure it and coordinate access. Removing that responsibility is a useful simplification for the person running a deployment.
But a deployment tool still needs to answer questions over time. Which resources belong to this configuration? What should happen when I remove one from the code? Which differences reflect my changes, and which come from the platform itself?
Those requirements exist whether the tool exposes a state file or keeps the necessary information somewhere else. My objection is to treating the absence of a state file as sufficient evidence of a simpler overall design. The work required to manage infrastructure has to be accounted for somewhere.
Deployment is only part of the lifecycle
With ordinary incremental ARM deployments, resources omitted from the template are left in place. Removing a resource declaration therefore does not, by itself, express the same lifecycle intent as removing a managed resource from a Terraform configuration.
That is a consequential difference for someone maintaining infrastructure. The code can stop describing a resource while the resource continues to exist. You need to understand the deployment model before you can reason about what removing that code actually means.
Deployment stacks provide an explicit management boundary. They track a group of managed resources and let you choose whether resources removed from the template are detached or deleted. They also offer deny settings to protect managed resources against unwanted changes.
These are useful capabilities. They bring Azure’s native tooling closer to the lifecycle management I expect from infrastructure as code. They also require the service to remember which resources it manages.
A small change still submits the whole template
Another source of friction is the deployment scope. I change one component, but submitting the same entry-point template still submits all the resources and modules it declares. I want the tooling to determine the necessary work without making me build that selection logic into the pipeline.
There is a distinction here: submitting everything does not mean Azure recreates or modifies every resource. Microsoft’s deployment-mode documentation says unchanged resources can result in no operation. But incremental deployment still describes the full resource configuration; it does not mean only the properties I edited are submitted as a patch.
Others have built workarounds for the deployment overhead. Paul McCormack’s deploy-changed-bicep-templates uses Git diff in a pipeline to select which templates to deploy based on changes to Bicep and parameter files. Its stated goal is to reduce deployment time for projects with multiple template sets that rarely change together.
That puts another responsibility into the pipeline: deciding which parts of the infrastructure need a deployment. File changes are also a different signal from infrastructure changes. A more general solution needs to account for shared modules, dependencies, parameter sources, and drift even when the repository has not changed.
I see this as another cost of the deployment model. A stateful tool still needs to inspect the infrastructure, but Terraform’s normal plan/apply workflow already gives me a resource-level plan of the operations required. With Bicep, narrowing which templates I submit becomes additional orchestration for me to design and maintain. Avoiding a state file has not made the overall workflow feel simpler.
A phased migration exposes the remaining friction
Consider a migration where the old infrastructure needs to keep serving traffic while replacement components are deployed and tested. I want to release selected resources from management, build the replacement gradually, and shift dependencies once everything is ready. Some obsolete resources can be deleted immediately; others must survive until the migration is complete.
In Terraform, I can remove the resources I want to preserve from state and code. They remain running. I can also express that intention in a reviewable configuration change using a removed block:
1 | removed { |
For a separate obsolete account, I remove its resource declaration and leave its state entry for Terraform to plan its deletion. The same plan can therefore express: preserve the legacy account, delete the obsolete one, and create the replacement components. The migration still requires application testing and a deliberate cutover, but the infrastructure tool lets me express those different lifecycle intentions together.
Deployment stacks support preservation through detachment. The friction is in the granularity: actionOnUnmanage selects detach or delete behaviour for resources becoming unmanaged during an update. It does not give each ordinary resource its own preservation decision within that update.
For two storage accounts in the same stack, that means sequencing the work. First remove the legacy account from the template and update with --action-on-unmanage detachAll, keeping the obsolete account declared. Then remove the obsolete account and update with --action-on-unmanage deleteResources. Alternatively, arrange separate stacks around the different lifecycle requirements.
Both approaches can achieve the migration. But in the stack workflow, I have to turn a distinction between two resources into a distinction between deployment operations or management boundaries. That is additional orchestration imposed by the model.
This is why deployment stacks do not entirely resolve my criticism. Even after adding explicit resource management, the design still pushes a straightforward migration intention into a workaround. Terraform lets me describe that intention directly in one change. With stacks, I have to organise the workflow around the tool’s policy granularity. To me, that is a less fluent experience.
The baseline makes the trade-off visible
What-If noise was one practical manifestation of the problem for me. The output was too noisy for the pipeline approval review I needed, so I published what-really-if, a helper that produces a more readable report and filters specific known differences while keeping uncertainty visible.
Microsoft now has a more contextual solution for stacks. Its noise-reduction documentation explains that Azure runs What-If after a successful stack deployment and stores the result as a baseline. Later evaluations suppress matching differences already present in that baseline. New differences can still appear, and the documentation explicitly warns that an unchanged file is not guaranteed to produce an empty preview.
The crucial detail is the stored baseline. Azure retains information from a previous deployment to interpret a later one more usefully.
This is persisted state managed by Azure. It is not equivalent to Terraform’s state file: the baseline records preview noise, while Terraform state serves broader purposes. But it illustrates the architectural point. Remembering prior context enables behaviour that a comparison of the current template and live resources alone could not provide as effectively.
Terraform had already demonstrated the value
HashiCorp’s explanation of Terraform state describes why it retains resource mappings and dependency information, including dependencies needed when a resource has been removed from the configuration. It also describes early prototypes without state files and the problems that approach encountered.
The value of retaining context was already established. Microsoft was not pioneering infrastructure as code with Bicep, and I expected its design to benefit more from that existing experience.
My reading of deployment stacks is that Microsoft has moved toward a more explicit model of ownership, lifecycle, and remembered context. That is an improvement. It also reinforces my criticism of the original trade-off: avoiding a user-managed state file did not eliminate the need for stateful management.
The caveats still shape the experience
State does not explain every surprising rule in Bicep. Features such as @onlyIfNotExists(), which leaves an existing resource unchanged, introduce lifecycle behaviour that users need to discover and understand. I found those rules unintuitive compared with Terraform, even where documentation exists.
Taken together, these encounters made Bicep feel more cumbersome than I expected from a tool designed specifically for Azure by Microsoft itself.
Deployment stacks deserve credit for improving that experience. My broader expectation remains: infrastructure tooling should offer a coherent model for creating, changing, reviewing, and retiring resources. I would have preferred Microsoft to build more of that lifecycle into the approach from the beginning. Moving the responsibility for state into Azure is valuable. The design still needs to acknowledge why that state is necessary.
A familiar disappointment
I had a similar reaction when I first encountered Azure AD B2C. It felt like an early developer prototype rather than a fully fledged product. About two years after that encounter, Microsoft announced the move toward Microsoft Entra External ID. For me, External ID now delivers the coherent product experience I had expected from a Microsoft product in the first place.
To be precise about the transition: Azure AD B2C became unavailable to new customers on May 1, 2025. Existing customers can continue using it, with support promised until at least May 2030. Microsoft provides guidance on the transition to External ID.
Perhaps Bicep will see a similar rethink. That is speculation on my part, and deployment stacks may already be part of the evolution toward a better experience. I would welcome it. A great native infrastructure-as-code solution for Azure is desirable, and I want Microsoft’s tooling to fulfil that promise.
If you deploy Bicep or ARM templates without deployment stacks and still need to cut down What-If noise, my published what-really-if scripts are available in Bash and PowerShell. You can tailor the filtering rules to your resources and review needs, while keeping suppressed differences and unknown effects visible for inspection.