|
| 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/26/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 | +Deleting a deployment from the history doesn't affect any of the resources that were deployed. |
| 14 | + |
| 15 | +## When deployments are deleted |
| 16 | + |
| 17 | +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 deployment history remains unchanged. The oldest deployments are always deleted first. |
| 18 | + |
| 19 | +## Opt out of automatic deletions |
| 20 | + |
| 21 | +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. |
| 22 | + |
| 23 | +To disable automatic deletions, register the `Microsoft.Resources/DisableDeploymentGrooming` feature flag. You apply the flag to each subscription that you want to opt out of automatic deletions. |
| 24 | + |
| 25 | +# [PowerShell](#tab/azure-powershell) |
| 26 | + |
| 27 | +For PowerShell, use [Register-AzProviderFeature](/powershell/module/az.resources/Register-AzProviderFeature). |
| 28 | + |
| 29 | +```azurepowershell-interactive |
| 30 | +Register-AzProviderFeature -ProviderNamespace Microsoft.Resources -FeatureName DisableDeploymentGrooming |
| 31 | +``` |
| 32 | + |
| 33 | +To see the current status of your subscription, use: |
| 34 | + |
| 35 | +```azurepowershell-interactive |
| 36 | +Get-AzProviderFeature -ProviderNamespace Microsoft.Resources -FeatureName DisableDeploymentGrooming |
| 37 | +``` |
| 38 | + |
| 39 | +# [Azure CLI](#tab/azure-cli) |
| 40 | + |
| 41 | +For Azure CLI, use [az feature register](/cli/azure/feature#az-feature-register). |
| 42 | + |
| 43 | +```azurecli-interactive |
| 44 | +az feature register --namespace Microsoft.Resources --name DisableDeploymentGrooming |
| 45 | +``` |
| 46 | + |
| 47 | +To see the current status of your subscription, use: |
| 48 | + |
| 49 | +```azurecli-interactive |
| 50 | +az feature show --namespace Microsoft.Resources --name DisableDeploymentGrooming |
| 51 | +``` |
| 52 | + |
| 53 | +# [REST](#tab/rest) |
| 54 | + |
| 55 | +For REST API, use [Features - Register](/rest/api/resources/features/register). |
| 56 | + |
| 57 | +```rest |
| 58 | +POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Resources/features/DisableDeploymentGrooming/register?api-version=2015-12-01 |
| 59 | +``` |
| 60 | + |
| 61 | +To see the current status of your subscription, use: |
| 62 | + |
| 63 | +```rest |
| 64 | +GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Resources/features/DisableDeploymentGrooming/register?api-version=2015-12-01 |
| 65 | +``` |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## Next steps |
| 70 | + |
| 71 | +* To learn about viewing the deployment history, see [View deployment history with Azure Resource Manager](deployment-history.md). |
0 commit comments