You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/deployment-stacks.md
+69-21Lines changed: 69 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ ms.date: 05/28/2024
8
8
9
9
# Deployment stacks
10
10
11
-
An Azure deployment stack is a type of Azure resource that enables the management of a group of Azure resources as an atomic unit. When a Bicep file or an ARM JSON template is submitted to a deployment stack, it defines the resources that are managed by the stack. If a resource that was previously included in the template is removed, it will either be detached or deleted based on the specified _actionOnUnmanage_ behavior of the deployment stack. Similar to other Azure resources, access to the deployment stack can be restricted using Azure role-based access control (Azure RBAC).
11
+
An Azure deployment stack is a resource that enables you to manage a group of Azure resources as a single, cohesive unit. When you submit a Bicep file or an ARM JSON template to a deployment stack, it defines the resources that the stack manage. If a resource previously included in the template is removed, it will either be detached or deleted based on the specified _actionOnUnmanage_ behavior of the deployment stack. Access to the deployment stack can be restricted using Azure role-based access control (Azure RBAC), similar to other Azure resources.
12
12
13
13
To create and update a deployment stack, you can utilize Azure CLI, Azure PowerShell, or the Azure portal along with Bicep files. These Bicep files are transpiled into ARM JSON templates, which are then deployed as a deployment object by the stack. The deployment stack offers additional capabilities beyond the [familiar deployment resources](./deploy-cli.md), serving as a superset of those capabilities.
14
14
15
15
`Microsoft.Resources/deploymentStacks` is the resource type for deployment stacks. It consists of a main template that can perform 1-to-many updates across scopes to the resources it describes, and block any unwanted changes to those resources.
16
16
17
-
When planning your deployment and determining which resource groups should be part of the same stack, it's important to consider the management lifecycle of those resources, which includes creation, updating, and deletion. For instance, suppose you need to provision some test VMs for various application teams across different resource group scopes. In this case, a deployment stack can be utilized to create these test environments and update the test VM configurations through subsequent updates to the deployment stack. After completing the project, it may be necessary to remove or delete any resources that were created, such as the test VMs. By utilizing a deployment stack, the managed resources can be easily removed by specifying the appropriate delete flag. This streamlined approach saves time during environment cleanup, as it involves a single update to the stack resource rather than individually modifying or removing each test VM across various resource group scopes.
17
+
When planning your deployment and determining which resource groups should be part of the same stack, it's important to consider the management lifecycle of those resources, which includes creation, updating, and deletion. For instance, suppose you need to provision some test virtual machines(VM) for various application teams across different resource group scopes. In this case, a deployment stack can be utilized to create these test environments and update the test VM configurations through subsequent updates to the deployment stack. After completing the project, it may be necessary to remove or delete any resources that were created, such as the test VMs. By utilizing a deployment stack, the managed resources can be easily removed by specifying the appropriate delete flag. This streamlined approach saves time during environment cleanup, as it involves a single update to the stack resource rather than individually modifying or removing each test VM across various resource group scopes.
18
18
19
19
Deployment stacks requires Azure PowerShell [version 12.0.0 or later](/powershell/azure/install-az-ps) or Azure CLI [version 2.61.0 or later](/cli/azure/install-azure-cli).
20
20
@@ -24,24 +24,24 @@ To create your first deployment stack, work through [Quickstart: create deployme
24
24
25
25
Deployment stacks provide the following benefits:
26
26
27
-
-Simplified provisioning and management of resources across different scopes as a cohesive entity.
28
-
-Preventing undesired modifications to managed resources through[deny settings](#protect-managed-resources-against-deletion).
29
-
- Efficient environment cleanup by employing delete flags during deployment stack updates.
30
-
-Utilizing standard templates such as Bicep, ARM templates, or Template specs for your deployment stacks.
27
+
-Streamlined provisioning and management of resources across different scopes as a unified entity.
28
+
-Prevention of undesired modifications to managed resources via[deny settings](#protect-managed-resources-against-deletion).
29
+
- Efficient environment cleanup using delete flags during deployment stack updates.
30
+
-Use of standard templates such as Bicep, ARM templates, or Template specs for your deployment stacks.
31
31
32
32
### Known limitations
33
33
34
-
- Implicitly created resources aren't managed by the stack. Therefore, no denyassignments or cleanup is possible.
35
-
- Denyassignments don't support tags.
36
-
- Denyassignments are not supported at the management group scope. However, they are supported in a management group stack if the deployment is pointed at the subscription scope.
37
-
- Deployment stacks cannot delete Key vault secrets. If you're removing key vault secrets from a template, make sure to also execute the deployment stack update/delete command with detach mode.
34
+
- Implicitly created resources aren't managed by the stack. Therefore, no deny-assignments or cleanup is possible.
35
+
- Deny-assignments don't support tags.
36
+
- Deny-assignments aren't supported at the management group scope. However, they're supported in a management group stack if the deployment is pointed at the subscription scope.
37
+
- Deployment stacks can't delete Key vault secrets. If you're removing key vault secrets from a template, make sure to also execute the deployment stack update/delete command with detach mode.
38
38
39
39
### Known issues
40
40
41
-
- Deleting resource groups currently bypasses denyassignments. When creating a deployment stack in the resource group scope, the Bicep file doesn't contain the definition for the resource group. Despite the denyassignment setting, it's possible to delete the resource group and its contained stack. However, if a [lock](../management/lock-resources.md) is active on any resource within the group, the delete operation will fail.
42
-
- The [What-if](./deploy-what-if.md) support is not yet available.
41
+
- Deleting resource groups currently bypasses deny-assignments. When creating a deployment stack in the resource group scope, the Bicep file doesn't contain the definition for the resource group. Despite the deny-assignment setting, it's possible to delete the resource group and its contained stack. However, if a [lock](../management/lock-resources.md) is active on any resource within the group, the delete operation fails.
42
+
- The [What-if](./deploy-what-if.md) support isn't yet available.
43
43
- A management group-scoped stack is restricted from deploying to another management group. It can only deploy to the management group of the stack itself or to a child subscription.
44
-
- The PowerShell command help lists a `DeleteResourcesAndResourcesGroups` value for the `ActionOnUnmanage` switch. When this value is used, the command detaches the managed resources and the resource groups. This value will be removed in the next update. Do not use this value.
44
+
- The PowerShell command help lists a `DeleteResourcesAndResourcesGroups` value for the `ActionOnUnmanage` switch. When this value is used, the command detaches the managed resources and the resource groups. This value will be removed in the next update. Don't use this value.
45
45
46
46
## Built-in roles
47
47
@@ -50,8 +50,8 @@ Deployment stacks provide the following benefits:
50
50
51
51
There are two built-in roles for deployment stack:
52
52
53
-
-**Azure Deployment Stack Contributor**: Allows users to manage deployment stacks, but cannot create or delete denyassignments within the deployment stacks.
54
-
-**Azure Deployment Stack Owner**: Allows users to manage deployment stacks, including those with denyassignments.
53
+
-**Azure Deployment Stack Contributor**: Allows users to manage deployment stacks, but can't create or delete deny-assignments within the deployment stacks.
54
+
-**Azure Deployment Stack Owner**: Allows users to manage deployment stacks, including those with deny-assignments.
55
55
56
56
## Create deployment stacks
57
57
@@ -61,7 +61,7 @@ A deployment stack resource can be created at resource group, subscription, or m
61
61
- A stack at subscription scope can deploy the template passed-in to a resource group scope (if specified) or the same subscription scope where the deployment stack exists.
62
62
- A stack at management group scope can deploy the template passed-in to the subscription scope specified.
63
63
64
-
It's important to note that where a deployment stack exists, so is the denyassignment created with the deny settings capability. For example, by creating a deployment stack at subscription scope that deploys the template to resource group scope and with deny settings mode `DenyDelete`, you can easily provision managed resources to the specified resource group and block delete attempts to those resources. By using this approach, you also enhance the security of the deployment stack by separating it at the subscription level, as opposed to the resource group level. This separation ensures that the developer teams working with the provisioned resources only have visibility and write access to the resource groups, while the deployment stack remains isolated at a higher level. This minimizes the number of users that can edit a deployment stack and make changes to its denyassignment. For more information, see [Protect managed resource against deletion](#protect-managed-resources-against-deletion).
64
+
It's important to note that where a deployment stack exists, so is the deny-assignment created with the deny settings capability. For example, by creating a deployment stack at subscription scope that deploys the template to resource group scope and with deny settings mode `DenyDelete`, you can easily provision managed resources to the specified resource group and block delete attempts to those resources. By using this approach, you also enhance the security of the deployment stack by separating it at the subscription level, as opposed to the resource group level. This separation ensures that the developer teams working with the provisioned resources only have visibility and write access to the resource groups, while the deployment stack remains isolated at a higher level. This minimizes the number of users that can edit a deployment stack and make changes to its deny-assignment. For more information, see [Protect managed resource against deletion](#protect-managed-resources-against-deletion).
65
65
66
66
The create-stack commands can also be used to [update deployment stacks](#update-deployment-stacks).
The `DeploymentResourceGroupName` parameter specifies the resource group used to store the deployment stack resources. If you don't specify a resource group name, the deployment stack service will create a new resource group for you.
297
+
The `DeploymentResourceGroupName` parameter specifies the resource group used to store the deployment stack resources. If you don't specify a resource group name, the deployment stack service creates a new resource group for you.
298
298
299
299
# [CLI](#tab/azure-cli)
300
300
@@ -348,7 +348,7 @@ Currently not implemented.
348
348
349
349
### Use the New command
350
350
351
-
You get a warning similar to the following:
351
+
You get a warning similar to the following one:
352
352
353
353
```warning
354
354
The deployment stack 'myStack' you're trying to create already exists in the current subscription/management group/resource group. Do you want to overwrite it? Detaching: resources, resourceGroups (Y/N)
@@ -408,6 +408,54 @@ Currently not implemented.
408
408
> [!WARNING]
409
409
> When deleting resource groups with the action-on-unmanage switch set to `DeleteAll`, the managed resource groups and all the resources contained within them will also be deleted.
410
410
411
+
### Handle the stack-out-of-sync error
412
+
413
+
When updating or deleting a deployment stack, you might encounter the following stack-out-of-sync error, indicating the stack resource list isn't correctly synchronized.
414
+
415
+
```error
416
+
The deployment stack '{0}' may not have an accurate list of managed resources. To ensure no resources are accidentally deleted, please check that the managed resource list does not have any additional values. If there is any uncertainty, we recommend redeploying the stack with the same template and parameters as the current iteration. To bypass this warning, please specify the 'BypassStackOutOfSyncError' flag.
417
+
```
418
+
419
+
You can obtain a list of the resources from the Azure portal or redeploy the currently deployed Bicep file with the same parameters. The output shows the managed resources
1. Open the Resource group that contains the stack.
452
+
1. From the left menu, expand **Settings**, and then select **Deployment stacks**.
453
+
1. Select the stack name to open the stack.
454
+
455
+
---
456
+
457
+
After you have reviewed and verified the list of resources in the stack, you can rerun the command with the `BypassStackOutOfSyncError` switch in Azure PowerShell (or `bypass-stack-out-of-sync-error` in Azure CLI). This switch should only be used after thoroughly review the list of resources in the stack before rerunning the command. This switch should never be used by default.
458
+
411
459
## Delete deployment stacks
412
460
413
461
# [PowerShell](#tab/azure-powershell)
@@ -434,7 +482,7 @@ Select one of the delete flags when you delete a deployment stack.
434
482
435
483
---
436
484
437
-
Even if you specify the deleteall switch, if there are unmanaged resources within the resource group where the deployment stack is located, both the unmanaged resource and the resource group itself won't be deleted.
485
+
Even if you specify the delete-all switch, unmanaged resources within the resource group where the deployment stack is located prevents both the unmanaged resources and the resource group itself from being deleted.
438
486
439
487
To delete deployment stack resources at the resource group scope:
440
488
@@ -629,7 +677,7 @@ When creating a deployment stack, it's possible to assign a specific type of per
629
677
630
678
# [PowerShell](#tab/azure-powershell)
631
679
632
-
The Azure PowerShell includes these parameters to customize the denyassignment:
680
+
The Azure PowerShell includes these parameters to customize the deny-assignment:
633
681
634
682
-`DenySettingsMode`: Defines the operations that are prohibited on the managed resources to safeguard against unauthorized security principals attempting to delete or update them. This restriction applies to everyone unless explicitly granted access. The values include: `None`, `DenyDelete`, and `DenyWriteAndDelete`.
635
683
-`DenySettingsApplyToChildScopes`: Deny settings are applied to nested resources under managed resources.
@@ -638,7 +686,7 @@ The Azure PowerShell includes these parameters to customize the deny assignment:
638
686
639
687
# [CLI](#tab/azure-cli)
640
688
641
-
The Azure CLI includes these parameters to customize the denyassignment:
689
+
The Azure CLI includes these parameters to customize the deny-assignment:
642
690
643
691
-`deny-settings-mode`: Defines the operations that are prohibited on the managed resources to safeguard against unauthorized security principals attempting to delete or update them. This restriction applies to everyone unless explicitly granted access. The values include: `none`, `denyDelete`, and `denyWriteAndDelete`.
644
692
-`deny-settings-apply-to-child-scopes`: Deny settings are applied to nested resources under managed resources.
0 commit comments