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
Spring Cloud Azure updates and troubleshooting tips for Java on AKS
This post shows the latest Spring Cloud Azure updates. The post Spring Cloud Azure updates and troubleshooting tips for Java on AKS appeared f...
Episode 395 – Getting Started with VDI in Azure with Azure Virtual Desktop
Welcome to Episode 395 of the Microsoft Cloud IT Pro Podcast. In this episode, we dive into Azure Virtual Desktop (AVD) and how it enables org...
Azure AI Agents are in the Public Preview
AI agents are becoming a key enabler for businesses looking to streamline processes, automate repetitive tasks, and empower their employees to...
Simplify your .NET data transfers with the new Azure Storage Data Movement library
This post announces the new and improved Azure Storage Data Movement library for .NET. The post Simplify your .NET data transfers with the new...
External REST Endpoint Invocation in Azure SQL Managed Instance is now in Public Preview
External REST Endpoint Invocation is available in Azure SQL Managed Instance with the Always-up-to-date update policy configured. Call Azure S...
Announcing the end of support for Node.js 18.x in the Azure SDK for JavaScript
After July 10, 2025, the Azure SDK for JavaScript will no longer support Node.js 18.x. Upgrade to an Active Node.js Long Term Support (LTS) ve...
February Patches for Azure DevOps Server
Today we are releasing patches that impact our self-hosted product, Azure DevOps Server. We strongly encourage and recommend that all customer...
Primer: Using Exchange Online PowerShell in Azure Automation Runbooks
In this primer, we cover how to create and execute Azure Automation Exchange Online runbooks (scripts) using cmdlets from the Exchange Online ...
Azure Developer CLI (azd) – February 2025
This post announces the February release of the Azure Developer CLI (`azd`). The post Azure Developer CLI (azd) – February 2025 appeared...