Skip to content

Commit 20fd6ba

Browse files
authored
Merge pull request #300249 from mumian/0521-auto-delete-scope
Clarify deployment history auto deletion scopes
2 parents 9be9cf1 + 87b6ea8 commit 20fd6ba

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

articles/azure-resource-manager/templates/deployment-history-deletions.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,76 @@
22
title: Deployment history deletions
33
description: Describes how Azure Resource Manager automatically deletes deployments from the deployment history. Deployments are deleted when the history is close to exceeding the limit of 800.
44
ms.topic: conceptual
5-
ms.date: 04/28/2025
5+
ms.date: 05/27/2025
66
ms.custom: devx-track-azurecli, devx-track-arm-template
77
---
88

99
# Automatic deletions from deployment history
1010

11-
Every time you deploy a template, information about the deployment is written to the deployment history. Each resource group is limited to 800 deployments in its deployment history.
12-
13-
Azure Resource Manager automatically deletes deployments from your history as you near the limit. Automatic deletion is a change from past behavior. Previously, you had to manually delete deployments from the deployment history to avoid getting an error. This change was implemented on August 6, 2020.
11+
When you deploy resources to Azure, the deployment details are recorded in the deployment history at the scope where the deployment occurs. Each scope—whether it's a [resource group](./deploy-to-resource-group.md), [subscription](./deploy-to-subscription.md), [management group](./deploy-to-management-group.md), [tenant](./deploy-to-tenant.md)—can store up to **800 deployments** in its history. Once this limit is reached, Azure **automatically deletes the oldest deployments** to make space for new ones. This automatic cleanup process was implemented on **August 6, 2020**.
1412

1513
> [!NOTE]
1614
> Deleting a deployment from the history doesn't affect any of the resources that were deployed.
1715
18-
## When deployments are deleted
16+
## Overview of automatic deployment history deletions
1917

2018
Deployments are deleted from your history when you exceed 700 deployments. Azure Resource Manager deletes deployments until the history is down to 600. The oldest deployments are always deleted first.
2119

2220
:::image type="content" border="false" source="./media/deployment-history-deletions/deployment-history.png" alt-text="Diagram of deployment history deletion.":::
2321

2422
> [!IMPORTANT]
25-
> If your resource group is already at the 800 limit, your next deployment fails with an error. The automatic deletion process starts immediately. You can try your deployment again after a short wait.
23+
> If your scope is already at the 800 limit, your next deployment fails with an error. The automatic deletion process starts immediately. You can try your deployment again after a short wait.
2624
2725
In addition to deployments, you also trigger deletions when you run the [what-if operation](./deploy-what-if.md) or validate a deployment.
2826

2927
When you give a deployment the same name as one in the history, you reset its place in the history. The deployment moves to the most recent place in the history. You also reset a deployment's place when you [roll back to that deployment](rollback-on-error.md) after an error.
3028

31-
## Remove locks that block deletions
29+
## Permissions required for automatic deletions
30+
31+
The deletions are requested under the identity of the user who deployed the template. To delete deployments, the user must have access to the **Microsoft.Resources/deployments/delete** action. If the user doesn't have the required permissions, deployments aren't deleted from the history.
32+
33+
If the current user doesn't have the required permissions, automatic deletion is attempted again during the next deployment.
34+
35+
## Handling resource locks
36+
37+
If you have a [CanNotDelete lock](../management/lock-resources.md) on a resource group or a subscription, the deployments for that scope can't be automatically deleted. To enable automatic cleanup of the deployment history, you need to remove the lock.
3238

33-
If you have a [CanNotDelete lock](../management/lock-resources.md) on a resource group, the deployments for that resource group can't be deleted. You must remove the lock to take advantage of automatic deletions in the deployment history.
39+
To delete a resource group lock, run the following commands:
3440

35-
To use PowerShell to delete a lock, run the following commands:
41+
### [PowerShell](#tab/azure-powershell)
3642

3743
```azurepowershell-interactive
3844
$lockId = (Get-AzResourceLock -ResourceGroupName lockedRG).LockId
3945
Remove-AzResourceLock -LockId $lockId
4046
```
4147

42-
To use Azure CLI to delete a lock, run the following commands:
48+
To delete a resource group lock, run the following commands:
49+
50+
### [Azure CLI](#tab/azure-cli)
4351

4452
```azurecli-interactive
4553
lockid=$(az lock show --resource-group lockedRG --name deleteLock --output tsv --query id)
4654
az lock delete --ids $lockid
4755
```
4856

49-
## Required permissions
57+
### [REST](#tab/rest)
5058

51-
The deletions are requested under the identity of the user who deployed the template. To delete deployments, the user must have access to the **Microsoft.Resources/deployments/delete** action. If the user doesn't have the required permissions, deployments aren't deleted from the history.
59+
```rest
60+
DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}?api-version=2016-09-01
61+
```
5262

53-
If the current user doesn't have the required permissions, automatic deletion is attempted again during the next deployment.
63+
---
5464

55-
## Opt out of automatic deletions
65+
## Opting out of automatic deletions
5666

57-
You can opt out of automatic deletions from the history. **Use this option only when you want to manage the deployment history yourself.** The limit of 800 deployments in the history is still enforced. If you exceed 800 deployments, you'll receive an error and your deployment will fail.
67+
You can opt out of automatic deletion to manually manage your deployment history. **Use this option cautiously**, as the **800-deployment limit** remains enforced, and exceeding it causes deployment failures.
5868

59-
To disable automatic deletions at the tenant or the management group scope, open a support ticket. For the instructions, see [Request support](./overview.md#get-support).
69+
> [!IMPORTANT]
70+
> Opting out is available only for subscription scopes, as it's controlled by the subscription-level `Microsoft.Resources/DisableDeploymentGrooming` feature flag. You can't opt out for only a particular resource group. For tenant or management group scopes, open a [support ticket](./overview.md#get-support) to disable automatic deletion.
6071
61-
To disable automatic deletions at the subscription scope, register the `Microsoft.Resources/DisableDeploymentGrooming` feature flag. When you register the feature flag, you opt out of automatic deletions for the entire Azure subscription. You can't opt out for only a particular resource group. To reenable automatic deletions, unregister the feature flag.
72+
To disable automatic deletion at the subscription scope (affects all resource groups within it):
6273

63-
# [PowerShell](#tab/azure-powershell)
74+
### [PowerShell](#tab/azure-powershell)
6475

6576
For PowerShell, use [Register-AzProviderFeature](/powershell/module/az.resources/Register-AzProviderFeature).
6677

@@ -76,7 +87,7 @@ Get-AzProviderFeature -ProviderNamespace Microsoft.Resources -FeatureName Disabl
7687

7788
To reenable automatic deletions, use Azure REST API or Azure CLI.
7889

79-
# [Azure CLI](#tab/azure-cli)
90+
### [Azure CLI](#tab/azure-cli)
8091

8192
For Azure CLI, use [az feature register](/cli/azure/feature#az-feature-register).
8293

@@ -96,7 +107,7 @@ To reenable automatic deletions, use [az feature unregister](/cli/azure/feature#
96107
az feature unregister --namespace Microsoft.Resources --name DisableDeploymentGrooming
97108
```
98109

99-
# [REST](#tab/rest)
110+
### [REST](#tab/rest)
100111

101112
For REST API, use [Features - Register](/rest/api/resources/features/register).
102113

includes/azure-resource-groups-limits.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ms.topic: include
55
ms.date: 10/25/2024
66
ms.author: jgao
77
---
8+
89
| Resource | Limit |
910
| --- | --- |
1011
| Resources per [resource group](../articles/azure-resource-manager/management/overview.md#resource-groups) | Resources aren't limited by resource group. Instead, they're limited by resource type in a resource group. See next row. |

includes/management-group-limits.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
| Direct parent management group per management group | One |
1919
| [Management group level deployments](../articles/azure-resource-manager/templates/deploy-to-management-group.md) per location | 800<sup>2</sup> |
2020
| Locations of [Management group level deployments](../articles/azure-resource-manager/templates/deploy-to-management-group.md) | 10 |
21+
| Deployments per management group in the deployment history |800<sup>3</sup> |
2122

2223
<sup>1</sup>The 6 levels don't include the subscription level.
2324

2425
<sup>2</sup>If you reach the limit of 800 deployments, delete deployments from the history that are no longer needed. To delete management group level deployments, use [Remove-AzManagementGroupDeployment](/powershell/module/az.resources/Remove-AzManagementGroupDeployment) or [az deployment mg delete](/cli/azure/deployment/mg#az-deployment-mg-delete).
26+
27+
<sup>3</sup>Deployments are automatically deleted from the history as you near the limit. Deleting an entry from the deployment history doesn't affect the deployed resources. For more information, see [Automatic deletions from deployment history](../articles/azure-resource-manager/templates/deployment-history-deletions.md).

0 commit comments

Comments
 (0)