|
2 | 2 | title: Deployment history deletions
|
3 | 3 | 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.
|
4 | 4 | ms.topic: conceptual
|
5 |
| -ms.date: 05/21/2025 |
| 5 | +ms.date: 05/22/2025 |
6 | 6 | ms.custom: devx-track-azurecli, devx-track-arm-template
|
7 | 7 | ---
|
8 | 8 |
|
9 | 9 | # Automatic deletions from deployment history
|
10 | 10 |
|
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. |
14 |
| - |
15 |
| - |
16 |
| - |
17 |
| - |
18 |
| -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. |
19 |
| - |
20 |
| -Azure Resource Manager automatically deletes deployments from your history as you near the limit. **Automatic deployment deletion applies to all scopes: resource group, subscription, and management group.** 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. |
21 |
| - |
22 |
| - |
23 |
| - |
24 |
| - |
25 |
| - |
| 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, subscription, or management group—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 has been in effect since **August 6, 2020**. |
26 | 12 |
|
27 | 13 | > [!NOTE]
|
28 | 14 | > Deleting a deployment from the history doesn't affect any of the resources that were deployed.
|
29 | 15 |
|
30 |
| -## When deployments are deleted |
| 16 | +## How automatic deployment deletions work |
31 | 17 |
|
32 | 18 | 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.
|
33 | 19 |
|
34 | 20 | :::image type="content" border="false" source="./media/deployment-history-deletions/deployment-history.png" alt-text="Diagram of deployment history deletion.":::
|
35 | 21 |
|
36 | 22 | > [!IMPORTANT]
|
37 |
| -> 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. |
38 | 24 |
|
39 | 25 | In addition to deployments, you also trigger deletions when you run the [what-if operation](./deploy-what-if.md) or validate a deployment.
|
40 | 26 |
|
41 | 27 | 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.
|
42 | 28 |
|
43 |
| -## Remove locks that block deletions |
| 29 | +## Permissions required for automatic deletions |
44 | 30 |
|
45 |
| -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. |
| 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 | +## Removing locks that block deletions |
| 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'll need to remove the lock. |
46 | 38 |
|
47 |
| -To use PowerShell to delete a lock, run the following commands: |
| 39 | +To delete a resource group lock using Azure PowerShell, run the following commands: |
48 | 40 |
|
49 | 41 | ```azurepowershell-interactive
|
50 | 42 | $lockId = (Get-AzResourceLock -ResourceGroupName lockedRG).LockId
|
51 | 43 | Remove-AzResourceLock -LockId $lockId
|
52 | 44 | ```
|
53 | 45 |
|
54 |
| -To use Azure CLI to delete a lock, run the following commands: |
| 46 | +To delete a resource group lock using Azure CLI, run the following commands: |
55 | 47 |
|
56 | 48 | ```azurecli-interactive
|
57 | 49 | lockid=$(az lock show --resource-group lockedRG --name deleteLock --output tsv --query id)
|
58 | 50 | az lock delete --ids $lockid
|
59 | 51 | ```
|
60 | 52 |
|
61 |
| -## Required permissions |
62 |
| - |
63 |
| -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. |
64 |
| - |
65 |
| -If the current user doesn't have the required permissions, automatic deletion is attempted again during the next deployment. |
66 |
| - |
67 |
| -## Opt out of automatic deletions |
| 53 | +## How to opt out of automatic deletions |
68 | 54 |
|
69 | 55 | 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.
|
70 | 56 |
|
|
0 commit comments