diff --git a/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/BlobModularTenantEvents.cs b/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/BlobModularTenantEvents.cs
new file mode 100644
index 00000000000..5803cf30503
--- /dev/null
+++ b/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/BlobModularTenantEvents.cs
@@ -0,0 +1,39 @@
+using Azure.Storage.Blobs;
+using Microsoft.Extensions.Logging;
+using OrchardCore.Environment.Shell.Removing;
+using OrchardCore.Modules;
+
+namespace OrchardCore.DataProtection.Azure;
+
+///
+/// A tenant event that deletes data protection blobs from a container when a tenant is deleted.
+///
+public class BlobModularTenantEvents : ModularTenantEvents
+{
+ private readonly BlobOptions _blobOptions;
+ private readonly ILogger _logger;
+
+ public BlobModularTenantEvents(
+ BlobOptions blobOptions,
+ ILogger logger)
+ {
+ _blobOptions = blobOptions;
+ _logger = logger;
+ }
+
+ ///
+ /// Removes the data protection blob from the container when a tenant is deleted.
+ ///
+ /// The
+ public async override Task RemovingAsync(ShellRemovingContext context)
+ {
+ var blobClient = new BlobClient(
+ _blobOptions.ConnectionString,
+ _blobOptions.ContainerName,
+ _blobOptions.BlobName);
+
+ _logger.LogDebug("Deleting blob '{BlobName}' from container '{ContainerName}'.", _blobOptions.BlobName, _blobOptions.ContainerName);
+
+ await blobClient.DeleteIfExistsAsync();
+ }
+}
diff --git a/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/Startup.cs b/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/Startup.cs
index a88327caf1a..f127898a043 100644
--- a/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/Startup.cs
+++ b/src/OrchardCore.Modules/OrchardCore.DataProtection.Azure/Startup.cs
@@ -39,6 +39,8 @@ public override void ConfigureServices(IServiceCollection services)
options.ContainerName,
options.BlobName);
});
+
+ services.AddScoped();
}
else
{