devdeer.Libraries.Azure.BlobStorage 0.7.0

dotnet add package devdeer.Libraries.Azure.BlobStorage --version 0.7.0
                    
NuGet\Install-Package devdeer.Libraries.Azure.BlobStorage -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="devdeer.Libraries.Azure.BlobStorage" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="devdeer.Libraries.Azure.BlobStorage" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="devdeer.Libraries.Azure.BlobStorage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add devdeer.Libraries.Azure.BlobStorage --version 0.7.0
                    
#r "nuget: devdeer.Libraries.Azure.BlobStorage, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package devdeer.Libraries.Azure.BlobStorage@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=devdeer.Libraries.Azure.BlobStorage&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=devdeer.Libraries.Azure.BlobStorage&version=0.7.0
                    
Install as a Cake Tool

devdeer.Libraries.Azure.BlobStorage

NuGet Downloads


Disclaimer


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.


Summary

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:

  • Simplified API for working with Azure Blob Storage.
  • Extensions methods for common operations.
  • Helper classes.
  • Asynchronous support using Task-based methods.
  • Configurable authentication.
  • Logging integration with .NET's built-in logging framework.

To use this library, follow these steps:

Installation

Add the library to your .NET project using NuGet:

dotnet add package devdeer.Libraries.Azure.BlobStorage

Documentation

The documentation is divided into several sections:

Authentication Methods

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:

1. Connection String
  • Description: Uses an explicit connection string which encapsulates all required authentication details.
  • Usage: Supply a complete connection string directly in your configuration.
  • Example:
    {
      "BlobStorageOptions": {
        "ConnectionString": "storage-account-connection-string"
      }
    }
    
2. Account Name + Account Key
  • Description: Uses the storage account's name and key to create an authenticated client.
  • Usage: Provide both AccountName and AccountKey in your configuration. The package will construct the connection string dynamically if an explicit connection string is not provided.
  • Example:
    {
      "BlobStorageOptions": {
        "AccountName": "storage-account-name",
        "AccountKey": "storage-account-key"
      }
    }
    
3. Default Azure Credential + Account Name
  • Description: Leverages the 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.
  • Usage: Provide the 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.).
  • Example:
    {
      "BlobStorageOptions": {
        "AccountName": "storage-account-name"
      }
    }
    
  • Remarks:
    • Ensure that your environment is configured with the necessary credentials (e.g., through environment variables or managed identity).
    • Consider enabling Managed Identity on your Azure resources.

Injecting and Using the Blob Storage Logic

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.
        }
    }
}

About DEVDEER

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:

Website

GitHub GitHub Org's stars

YouTube YouTube Channel Subscribers YouTube Channel Views

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0 0 12/20/2025
0.6.0 101 12/13/2025
0.5.1 166 11/28/2025
0.5.0 438 11/20/2025
0.4.1 219 11/9/2025
0.4.0 199 11/9/2025
0.3.17-beta 129 11/7/2025
0.3.16-beta 207 10/21/2025
0.3.15-beta 113 10/18/2025
0.3.14-beta 163 10/15/2025
0.3.13-beta 109 10/11/2025
0.3.12-beta 110 10/11/2025
0.3.11-beta 166 10/7/2025
0.3.10-beta 167 10/7/2025
0.3.9-beta 165 10/7/2025
0.3.8-beta 168 10/6/2025
0.3.7-beta 99 10/4/2025
0.3.6-beta 113 9/27/2025
0.3.5-beta 227 8/28/2025
0.3.4-beta 186 8/13/2025
0.3.3-beta 151 7/29/2025
0.3.1-beta 154 7/29/2025
0.3.0-beta 177 7/16/2025
0.2.5-beta 185 7/14/2025
0.2.4-beta 142 5/30/2025
0.2.3-beta 233 5/16/2025
0.2.0-beta 173 4/11/2025
0.1.5-beta 198 4/3/2025
0.1.4-beta 190 3/18/2025
0.1.3-beta 183 3/18/2025
0.1.2-beta 370 3/17/2025
0.1.1-beta 325 2/14/2025

- BREAKING CHANGES:
- OperationResultModel is removed.
- Uploading now returns `BlobClient` instance.
- `CountBlobs` method is renamed to `GetBlobAmountAsync` and returns `int`.
- `GetContainerStatistics` method returns `ContainerStatisticsModel`.
- `DownloadToStreamAsync` now returns ready-to-read `Stream` with Position set to 0.
- `DownloadToPathAsync` now returns string with full path to the downloaded file.
- Renamed `DeleteIfExistsAsync` to `DeleteBlobIfExistsAsync` and changed return type to `ValueTask<bool>`
- Updated `DeleteContainerAsync` to return `Task`
- Added in logic:
- Copying of a blob within one or different containers (with metadata if needed)
- Moving of a blob within one or different containers (with metadata if needed)
- Getting properties of: Blob, Container, Blob Service
- Asynchronous iteration through blobs (FetchBlobsAsync)
- Batched deletion support. Automatic batches packing if blobs amount is greater than 256
- Deletion of all blobs in a container
- Deletion of a container
- Support for `null` or empty string as `prefix` argument in `CountBlobsAsync()` and `GetContainerStatisticsAsync()`,
which results in the same result as their simpler overloaded versions
- Support for optional cancellation token in upload methods
- In `DownloadToStreamAsync` optional `targetFileName` parameter
-Added in BlobStorageHelper:
- Getting URI of blob and container
-Added in MetadataHelper:
- Method which throws an exception with details if metadata is invalid
-Added `BlobClient` extension method:
- GetMetadataAsync for retrieving metadata of a blob as a dictionary
- Bug fixes:
- Fixed bug in DownloadToPathAsync, where the full blobs path was used as the file name
- While uploading a blob, failed metadata or HTTP headers setting won't cause a failed operation. URI of the blob will be returned.
- Package updates.