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 specified period, it ensures data integrity and availability, even in the event of human error. However, restoring data in the soft delete state can be more labor-intensive, as the undelete API must be called for each individual deleted blob. Currently, there is no option to bulk undelete all blobs.
In this blog, we provide a sample C# code that will help you restore soft-deleted data efficiently. The code leverages multiple threads to expedite the restoration process, making it particularly effective if you have a large number of blobs to restore. Additionally, this program can be configured to undelete blobs within a specific container or directory, rather than scanning the entire storage account.
To run this program, follow these steps:
- Install .NET SDK: Ensure you have the .NET SDK installed on your machine.
- Connect to Azure Account:
- Add NuGet Source:
- Create a New Console Application:
- Add the following code to Program.cs.
Replace xxxx with your specific storage account and container name. If you need to restore a particular directory, provide the directory name; otherwise, leave it empty to scan the entire container. The code is configured to run with 500 threads by default, but you can adjust this number according to your needs.
- Add Required Packages:
- Build the Project:
- Run the Program:
Once the application is running, you can monitor the console window to track its progress and identify any potential issues or failures.
Published on:
Learn moreRelated posts
Announcing the new Azure DevOps Server RC Release
We’re excited to announce the release candidate (RC) of Azure DevOps Server, bringing new features previously available in our hosted version....
How to Integrate Azure Service Bus with Microsoft Dynamics 365 CRM Step by Step with Example?
Keeping data flowing between applications is critical in today’s connected business world. Organizations using Microsoft Dynamics 365 CR...
Enhancing Secure Sign-Ins with Temporary Access Pass in Azure Active Directory
Introduction While working on improving user account recovery scenarios, a common challenge often arises: how to securely allow a user to sign...
Azure SDK Release (September 2025)
Azure SDK releases every month. In this post, you'll find this month's highlights and release notes. The post Azure SDK Release (September 202...
Batch Processing Triggered Pipeline Runs in Azure Synapse
This post describes a pattern for batch processing triggered pipeline runs in Azure Synapse
Reliably refreshing a Semantic Model from Azure Data Factory or Synapse Pipelines
This post describes a pattern for reliably refreshing Power BI semantic models from Azure Data Factory or Azure Synapse Pipelines.
Power Pages Fundamentals #24: Boosting Portal Security with Azure Single Sign-On: Quick Read Series
Contoso Motors is a large automotive service company.They have built a Power Pages customer portal for their external partners and customers t...