You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Azure Deployment Stacks are a native Azure feature that groups deployed resources into a managed collection, providing lifecycle management, drift protection, and deny settings. Deployment stacks build on top of ARM/Bicep deployments to solve governance challenges that individual deployments cannot address.
A deployment stack is an Azure resource that manages a collection of Azure resources as a single unit. When you create a deployment stack, you submit a Bicep or ARM template, and the stack tracks all resources it creates.
Key capabilities:
Standard ARM/Bicep deployments (incremental mode) do not track what happens to resources removed from a template. If you deploy a storage account and a VM, then later remove the VM from the template and redeploy, the VM remains — orphaned and unmanaged.
Complete mode solves this but is dangerous and only works at the resource group level.
With a deployment stack:
az stack group create \
--name webapp-stack \
--resource-group rg-webapp-prod \
--template-file main.bicep \
--parameters @parameters.prod.json \
--action-on-unmanage deleteResources \
--deny-settings-mode denyWriteAndDelete
az stack sub create \
--name platform-stack \
--location uksouth \
--template-file platform.bicep \
--parameters @parameters.json \
--action-on-unmanage deleteAll \
--deny-settings-mode denyDelete
az stack mg create \
--name governance-stack \
--management-group-id myManagementGroup \
--location uksouth \
--template-file governance.bicep \
--action-on-unmanage detachResources \
--deny-settings-mode none
When a resource is removed from the template, the deployment stack takes one of these actions:
| Action | Behaviour |
|---|---|
| deleteResources | Deletes resources but keeps resource groups and management groups |
| deleteAll | Deletes resources, resource groups, and management groups |
| detachResources | Removes resources from stack management but does not delete them |
Choose based on your governance needs:
Deny settings prevent unauthorised changes to resources managed by the stack:
| Mode | Effect |
|---|---|
| none | No restrictions; anyone with RBAC access can modify resources |
| denyDelete | Prevents deletion of managed resources |
| denyWriteAndDelete | Prevents both modifications and deletions |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.