Permanent Delete of Soft deleted Snapshot and Versions without disabling Soft Delete option
Background:
This blog covers Permanent Delete of Soft deleted Snapshot and Versions in Azure storage without disabling Soft Delete option before the retention period ends.
Permanent Delete of Blob Snapshot and Version:
With version 2020-02-10 and later, you can permanently delete a soft-deleted snapshot or version.
Permanent delete enables you to permanently delete a soft-deleted snapshot or blob version before the retention period ends.
Note
The storage account must have versioning or snapshots enabled. Soft-delete must also be enabled on the storage account to soft-delete versions or snapshots of blobs in the account. Permanent delete only deletes soft-deleted snapshots or versions.
Please refer to article Delete Blob (REST API) - Azure Storage | Microsoft Learn
Step1 :
- Enable Permanent delete for soft deleted items option from Azure Portal
Please note Permanent delete option can be enabled from Azure Portal at the moment only for GPv2 Storage account without Hierarchical namespace enabled Storage account.
- Enable Permanent delete for soft deleted items from REST API
Make use of Set Blob Service Properties Rest API to enable Permanent Delete
Reference document : Set Blob Service Properties (REST API) - Azure Storage | Microsoft Docs
Sample request :
Make use of Get Blob Service Properties Rest API to check whether the Permanent Delete is enabled on the storage account or not
Get Blob Service Properties (REST API) - Azure Storage | Microsoft Docs
Step 2 :
Permanent delete of Snapshot/ version
- Using REST API
Make use of Delete Blob Rest API to permanent delete soft deleted snapshot/Version
Storage accounts with permanent delete enabled can use the deletetype=permanent query parameter to permanently delete a soft-deleted snapshot or deleted blob version.
If the query parameter presents any of the following, Blob Storage returns a 409 error (Conflict):
- The permanent delete feature isn't enabled for the storage account.
- Neither versionid nor snapshot are provided.
- The specified snapshot or version isn't soft-deleted.
Permanent delete also includes a shared access signature permission to permanently delete a blob snapshot or blob version. For more information, see Create a service SAS.
To get the Snapshot or version id which needs to be deleted use List Blob : List Blobs (REST API) - Azure Storage | Microsoft Learn rest API. Make use of URI parameter include=snapshots/versions(based on requirement)
- snapshots: Specifies that snapshots should be included in the enumeration. Snapshots are listed from oldest to newest in the response.
-versions: Version 2019-12-12 and later. Specifies that versions of blobs should be included in the enumeration
Sample Rest API call to get Snapshot/version id :
Sample Rest API call to permanent delete the snapshot/versions:
- Using Azcopy
We can make use of Azcopy to Permanently delete the Blob version or snapshot.
Make use of --permanent-delete (string) switch, this is a preview feature that PERMANENTLY deletes soft-deleted snapshots/versions. Possible values include 'snapshots', 'versions', 'snapshotsandversions', 'none'. (default "none")
- Execute azcopy login( with AD Authentication)
The above command will delete all the Snapshots/Versions which is in soft deleted state
Note : Make Sure to assign Storage Blob Data Owner role for the user who is running the Azcopy or use SAS /Access Keys.
Refer below documents for more information
https://github.com/Azure/azure-storage-azcopy/releases/tag/v10.14.0
https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob#permanent-delete
Published on:
Learn moreRelated posts
Azure Storage - TLS 1.0 and 1.1 retirement
Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...
Efficient Management of Append and Page Blobs Using Azure Storage Actions
Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...
[Azure AI Search] Internal Server Error when creating CMK encrypted objects
Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...
Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate
Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...
Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat
Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...
Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#
Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...
Performing simple Azure Table Storage REST API operations using curl command.
The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...
Bulk delete all the old jobs from the batch account
Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...
Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases
In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...
[Azure Service Bus] JMS messages getting dead-lettered
The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...