Blob Expired but Still in Storage? Here’s the Cleanup Flow I Built

When I was building SnappShare, a file-sharing tool with auto-expiry, I ran into a subtle but critical issue:
Files were expiring for users, but not leaving storage.
Let me break down what happened, why it mattered, and how I fixed it using Azure Service Bus and Azure Functions.
The Problem: Lifecycle Wasn’t Precise Enough
Azure Blob Storage supports lifecycle management policies, but here’s the catch:
The minimum delay for deletion is 24 hours.
In SnappShare, users could share files that expired in 1 hour (using short-lived SAS tokens).
While access was blocked, the actual file remained in storage.
This isn’t an issue at low scale. But at high volume, you could get charged for redundant files that users can no longer access.
The Goal: Precise, On-Time Deletion
I wanted a system that:
Deletes files at their actual expiry time
Scales well and doesn't run 24/7
Offers visibility and error handling
The Solution: Custom Cleanup Flow
Here’s the simple but powerful workflow I implemented:
When a file is uploaded, I store the expiry time (e.g., 2 hours from now).
I send a scheduled message to an Azure Service Bus Queue that will unlock at that expiry time.
When the message is unlocked, an Azure Function is triggered to:
Delete the blob
Log success or failure
If needed, I can plug in a Topic + Subscription system to send expiry notifications.
Why This Works Better
Precise timing: Files are deleted exactly when they expire
Pay-as-you-go: Service Bus (Basic) + Azure Function (Consumption) = cost-efficient
Built-in retries: Functions can retry failed deletes
Observable: Add logs, alerts, or even notify users when cleanup happens
Is It Overkill?
You might ask: Why not just let lifecycle do its job?
Here’s why:
You don’t always want to wait 24+ hours
You don’t want surprises in your storage bill
You want control
Designing for precision helps keep your product sharp, fast, and scalable, especially for file-heavy SaaS.
Final Thoughts
Azure Blob Storage is powerful, but when you need more control over cleanup, pairing it with Service Bus and Functions gives you the power to design around failure and scale with confidence.
Built something similar or curious how it works under the hood?
Let’s talk on X → @freemancodz | Full repo → GitHub
#azure #blobstorage #serverless #servicebus #dotnetdeveloper #snappshare #cleanarchitecture #cloudengineering
Subscribe to my newsletter
Read articles from Freeman Madudili directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Freeman Madudili
Freeman Madudili
Hi, I’m Freeman, a Software Developer specializing in C#, .NET, and Azure. With a passion for creating seamless web and cloud solutions, I’ve built and deployed apps that solve real-world problems. Follow along as I share insights, projects, and tips from my journey in tech!