Azure Blob Storage implementation of IBlobService for .NET developers, backed by Azure.Storage.Blobs.
BlobServiceClientFactory is the hook
for DefaultAzureCredential, with no separate credential plumbing in your own code.CreateIfNotExistsAsync runs on first use, so a fresh environment needs no
manual container creation.GetPublicAccessUrl returns a SAS URI scoped to a single blob.DeleteAsync on a directory request walks the prefix tree and
removes nested blobs and folder markers for you.dotnet new console -f net10.0 -n AzureBlobDemo
cd AzureBlobDemo
dotnet add package DKNet.Svc.BlobStorage.AzureStorage
dotnet add package Microsoft.Extensions.Logging
using DKNet.Svc.BlobStorage.Abstractions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
var config = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?>
{
["BlobService:AzureStorage:ConnectionString"] = "UseDevelopmentStorage=true",
["BlobService:AzureStorage:ContainerName"] = "documents"
})
.Build();
var services = new ServiceCollection().AddLogging().AddAzureStorageAdapter(config);
using var provider = services.BuildServiceProvider();
var blobService = provider.GetRequiredService<IBlobService>();
var location = await blobService.SaveAsync(
new BlobDetails.BlobData("reports/monthly.pdf", BinaryData.FromString("...")) { Overwrite = true });
Console.WriteLine(location);
AddAzureStorageAdapter(IConfiguration) binds AzureStorageOptions from the "BlobService:AzureStorage" section
and registers IBlobService → AzureStorageBlobService as a process-lifetime singleton; the call is idempotent. A
second AddAzureStorageAdapter(Action<AzureStorageOptions>) overload exists — read its trap on the
configure page before reaching for it.
The diagram cannot show that BlobServiceClientFactory, when set, takes priority over ConnectionString for
building the underlying client — covered on the configure page.
Which of the two option properties you set decides how the BlobServiceClient is built, and that in turn decides
whether GetPublicAccessUrl can sign anything. The diagram does not show the per-call SaveAsync path or SAS
signing in detail — see the feature page below.
IBlobService contract, shared models, and validation that application code should depend on directly.