Wrapper for the official Azure BLOB Storage API.
$ dotnet add package devdeer.Libraries.Azure.BlobStorage
If you want to use this package you should be aware of some principles and practices we at DEVDEER use. So be aware that this is not backed by a public repository. The purpose here is to give out customers easy access to our logic. Nevertheless, you are welcome to use this lib if it provides any advantages.
This package is designed to simplify interactions with Azure BLOB Storage. It provides an abstraction layer over the Azure SDK, making it easier to perform common BLOB operations. It is primarily intended for internal DEVDEER projects, but it can be useful for any .NET-based application that integrates with Azure Storage.
Key Features:
To use this library, follow these steps:
Add the library to your .NET project using NuGet:
dotnet add package devdeer.Libraries.Azure.BlobStorage
The documentation is divided into several sections:
This module supports multiple ways to authenticate and interact with Azure Blob Storage. You can choose the method that best suits your deployment environment and security requirements. The supported methods are:
{
"BlobStorageOptions": {
"ConnectionString": "storage-account-connection-string"
}
}
AccountName and AccountKey in your configuration. The package will construct the connection string
dynamically if an explicit connection string is not provided.{
"BlobStorageOptions": {
"AccountName": "storage-account-name",
"AccountKey": "storage-account-key"
}
}
DefaultAzureCredential class from the Azure Identity library for authentication. This method is ideal
for environments where managed identities or developer credentials (e.g., Visual Studio, Azure CLI) are available.AccountName in your configuration. The module will use the DefaultAzureCredential to automatically
select the best available credential (e.g., environment variables, managed identity, Azure CLI credentials, etc.).{
"BlobStorageOptions": {
"AccountName": "storage-account-name"
}
}
To register our service in Program.cs, add the following dependency
injection configuration:
var builder = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
// Register options from configuration
services.RegisterOption<BlobStorageOptions>(BlobStorageOptions.ConfigurationKey);
// Register BLOB storage logic
services.AddScoped<IBlobStorageLogic, BlobStorageLogic>();
});
After registering the service, you can inject it into your classes and use it as needed. The example below demonstrates
injecting IBlobStorageLogic into a service and using it to upload a file:
public class CustomService
{
// Field for the BLOB storage logic instance.
private readonly IBlobStorageLogic _blobStorageLogic;
// Constructor with dependency injection.
public CustomService(IBlobStorageLogic blobStorageLogic)
{
_blobStorageLogic = blobStorageLogic;
}
// Method with Azure BLOB storage service implementation.
public async Task CustomMethod(...)
{
//...
BlobClient? blobClient = null;
try
{
// Upload the file to Azure Blob Storage.
var blobClient = await _blobStorageLogic.UploadAsync(fileStream, blobName, containerName);
}
catch(Exception ex)
{
// Handle exceptions.
}
}
}
DEVDEER is a company from Magdeburg, Germany which is specialized in consulting, project management and development. We are very focussed on Microsoft Azure as a platform to run our products and solutions in the cloud. So all of our backend components usually runs in this environment and is developed using .NET. In the frontend area we are using react and a huge bunch of packages to build our UIs.
You can find us online: