Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
The Soft Delete feature is currently in PREVIEW. See the Supplemental Terms of Use for Microsoft Azure Previews for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
The Soft Delete feature in Azure Compute Gallery (ACG) lets you recover accidentally deleted resources within a 7 day retention period. After this timeframe, the platform permanently deletes the resources. Currently, this feature is only available for ACG images.
Soft Delete is available for the following gallery types:
- Private
- Direct Shared Gallery
- Community Gallery
When a resource, such as an image, is deleted using Soft Delete, it isn't immediately removed from the system. Instead, it enters a soft-deleted state, during which it remains recoverable for up to seven days. This grace period gives you time to review and restore any resources that were mistakenly deleted, preventing permanent loss.
After the retention window expires, the deleted items are automatically purged and can't be recovered. Soft Delete is useful in environments where accidental deletions can disrupt workflows or cause data loss.
Prerequisites
- Register the Azure Compute Gallery Soft Delete feature in the Azure portal.
- Alternatively, register Azure Compute Gallery Soft Delete feature by running the following
az feature registercommand from CLI:az feature register --name SIGSoftDelete --namespace Microsoft.Compute - The minimum API version required to use Soft Delete is
2024-03-03.
Limitations
- Soft Delete is only supported in the Azure portal or Rest API with some limitations.
- You can't currently update the retention policy.
- Virtual Machine Apps Recovery isn't supported.
- Deleting a gallery or image definition with Soft Deleted resources isn't supported.
- Only the following users are allowed to enable Soft Delete: the owner of a subscription, user or service principal assigned to the Compute Gallery Sharing Admin role at the subscription or gallery level
- Not supported in National Clouds.
- You can't enable Soft Delete if the gallery or image definition and image version are in different locations.
- Virtual Machine Scale Sets in Flexible orchestration aren't compatible with the Soft Delete feature.
- When an image in a gallery with Soft Delete enabled has a failed provisioning state, it can't be deleted. The recommended workaround is to temporarily disable Soft Delete on the gallery, delete the image, and then re-enable Soft Delete.
Billing
Soft Delete is provided at no cost. After an image is soft deleted, only one replica per region is retained. You are charged for that single replica until the image is permanently deleted.
Enable Soft Delete on a gallery
You can enable Soft Delete on a new or existing gallery.
To enable Soft Delete on an existing gallery, send the following PUT request. As part of the request, include and set the Softdeletepolicy and isSoftDeleteEnabled values to true.
PUT
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{gallery-name}?api-version=2024-03-03
{
"properties": {
"softDeletePolicy": {
"isSoftDeleteEnabled": true
}
},
"location": "{location}
}
Soft delete an image
Once Soft Delete is enabled on a gallery, all images in the gallery are soft deleted.
To soft delete an image, send the following DELETE request on the resource you intend to delete.
DELETE
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{gallery-name}/images/{image-defination-name}/versions/{version-name}?api-version=2024-03-03
List all soft deleted images
View a list of soft deleted images in a gallery or image definition.
Send the following GET request on the resource of the image definition to list all the soft deleted images.
GET
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{gallery-name}/softDeletedArtifactTypes/Images/artifacts/{image-defination-name}/versions?api-version=2024-03-03
Recover a soft deleted image
In this example, we demonstrate how to recover a soft deleted image.
To recover soft deleted images in a gallery, send the following PUT request on the image version to be recovered along with the home region of the image.
PUT
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{gallery-name}/images/{image-defination-name}/versions/{version-name}?api-version=2024-03-03
{
"location": "eastus2euap"
}
Hard Delete an image
Hard Delete permanently deletes the image without the possibility of a recovery.
To hard delete an image in a gallery, send the following DELETE request on the image version.
DELETE
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{gallery-name}/softDeletedArtifactTypes/Images/artifacts/{image-defination-name}/versions/{version-name}?api-version=2024-03-03
Frequently Asked Questions
Does Soft Delete become effective immediately upon being enabled in the gallery?
Yes, as long as the soft delete operation completes successfully.
Can I enable Soft Delete on an existing gallery and instantly delete and recover images, or is there a delay?
Yes, as long as the soft delete operation completes successfully.
Can I update the retention period beyond seven days?
No, currently you can't update the retention period.
Can I delete a gallery or image definition that has soft deleted images?
No, you can either delete all the soft deleted images or disable soft delete on the gallery to delete the image definition.