|
| 1 | +--- |
| 2 | +title: Deployment history deletions |
| 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 | +ms.topic: conceptual |
| 5 | +ms.date: 05/27/2020 |
| 6 | +--- |
| 7 | +# Automatic deletions from deployment history |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +Starting in June 2020, 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. |
| 12 | + |
| 13 | +> [!NOTE] |
| 14 | +> Deleting a deployment from the history doesn't affect any of the resources that were deployed. |
| 15 | +
|
| 16 | +## When deployments are deleted |
| 17 | + |
| 18 | +Deployments are deleted from your deployment history only when you near the limit of 800. Azure Resource Manager deletes a small set of the oldest deployments to clear space for future deployments. Most of your history remains unchanged. The oldest deployments are always deleted first. |
| 19 | + |
| 20 | +:::image type="content" border="false" source="./media/deployment-history-deletions/deployment-history.svg" alt-text="Deletions from deployment history"::: |
| 21 | + |
| 22 | +In addition to deployments, you also trigger deletions when you run the [what-if operation](template-deploy-what-if.md) or validate a deployment. |
| 23 | + |
| 24 | +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. |
| 25 | + |
| 26 | +## Opt out of automatic deletions |
| 27 | + |
| 28 | +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. |
| 29 | + |
| 30 | +To disable automatic deletions, 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. |
| 31 | + |
| 32 | +# [PowerShell](#tab/azure-powershell) |
| 33 | + |
| 34 | +For PowerShell, use [Register-AzProviderFeature](/powershell/module/az.resources/Register-AzProviderFeature). |
| 35 | + |
| 36 | +```azurepowershell-interactive |
| 37 | +Register-AzProviderFeature -ProviderNamespace Microsoft.Resources -FeatureName DisableDeploymentGrooming |
| 38 | +``` |
| 39 | + |
| 40 | +To see the current status of your subscription, use: |
| 41 | + |
| 42 | +```azurepowershell-interactive |
| 43 | +Get-AzProviderFeature -ProviderNamespace Microsoft.Resources -FeatureName DisableDeploymentGrooming |
| 44 | +``` |
| 45 | + |
| 46 | +# [Azure CLI](#tab/azure-cli) |
| 47 | + |
| 48 | +For Azure CLI, use [az feature register](/cli/azure/feature#az-feature-register). |
| 49 | + |
| 50 | +```azurecli-interactive |
| 51 | +az feature register --namespace Microsoft.Resources --name DisableDeploymentGrooming |
| 52 | +``` |
| 53 | + |
| 54 | +To see the current status of your subscription, use: |
| 55 | + |
| 56 | +```azurecli-interactive |
| 57 | +az feature show --namespace Microsoft.Resources --name DisableDeploymentGrooming |
| 58 | +``` |
| 59 | + |
| 60 | +# [REST](#tab/rest) |
| 61 | + |
| 62 | +For REST API, use [Features - Register](/rest/api/resources/features/register). |
| 63 | + |
| 64 | +```rest |
| 65 | +POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Resources/features/DisableDeploymentGrooming/register?api-version=2015-12-01 |
| 66 | +``` |
| 67 | + |
| 68 | +To see the current status of your subscription, use: |
| 69 | + |
| 70 | +```rest |
| 71 | +GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Resources/features/DisableDeploymentGrooming/register?api-version=2015-12-01 |
| 72 | +``` |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## Next steps |
| 77 | + |
| 78 | +* To learn about viewing the deployment history, see [View deployment history with Azure Resource Manager](deployment-history.md). |
0 commit comments