DevelopmentHelpers.Storage.Core 11.0.0

dotnet add package DevelopmentHelpers.Storage.Core --version 11.0.0
                    
NuGet\Install-Package DevelopmentHelpers.Storage.Core -Version 11.0.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="DevelopmentHelpers.Storage.Core" Version="11.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevelopmentHelpers.Storage.Core" Version="11.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DevelopmentHelpers.Storage.Core" />
                    
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 DevelopmentHelpers.Storage.Core --version 11.0.0
                    
#r "nuget: DevelopmentHelpers.Storage.Core, 11.0.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 DevelopmentHelpers.Storage.Core@11.0.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=DevelopmentHelpers.Storage.Core&version=11.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DevelopmentHelpers.Storage.Core&version=11.0.0
                    
Install as a Cake Tool

DevelopmentHelpers.Storage.Core

A small library to simplify working with Azure Blob Storage, Azure FileShare, and local filesystem directories. It provides an easy-to-use API for uploading, downloading and syncing entire directory structures and individual files. The library supports both local and Azure storage implementations and integrates with dependency injection.

Key features

  • Unified IStorage interface with implementations for Azure Blob Storage and local filesystem.
  • Azure FileShare support via IAzureFileStorage implementation.
  • Upload/download entire directories and containers.
  • Upload large files in chunks (resumable/large-file friendly).
  • Container synchronization helpers (container-to-container and directory-to-container).
  • Create ZIP archives from containers.
  • Easy configuration using appsettings.json and dependency injection.
  • Multiple Azure auth modes via AzureAuthMode (DevelopmentStorage, ConnectionString, ManagedIdentity, UserToken).

Prerequisites

  • .NET 10
  • Azure Storage account (when using Azure implementations)

Configuration (appsettings.json)

Configuration is bound to DevelopmentHelpers.Storage.Core.Models.AzureConfiguration from the DevelopmentHelpers:AzureConfiguration section. The AuthMode property controls how the library authenticates.

Common structure

"DevelopmentHelpers": {
  "AzureConfiguration": {
    "ConnectionString": "<connection string or UseDevelopmentStorage=true>",
    "AuthMode": "<DevelopmentStorage|ConnectionString|ManagedIdentity|UserToken>",
    "AccountName": "<storage-account-name>",
    "TenantId": "<aad-tenant-id>",
    "ClientId": "<aad-client-id>",
    "ClientSecret": "<aad-client-secret>"
  },
  "AzureFileStorageConfiguration": {
    "ConnectionString": "<file-storage-connection-string>",
    "ShareName": "<share-name>"
  }
}

Only a subset of properties is required for each AuthMode.

AuthMode: DevelopmentStorage (Azurite)

Use the Azurite/emulator connection string:

"DevelopmentHelpers": {
  "AzureConfiguration": {
    "ConnectionString": "UseDevelopmentStorage=true",
    "AuthMode": "DevelopmentStorage"
  }
}

AuthMode: ConnectionString (production account key)

Use a full Azure Storage connection string:

"DevelopmentHelpers": {
  "AzureConfiguration": {
    "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net",
    "AuthMode": "ConnectionString"
  }
}

AuthMode: ManagedIdentity

Use a managed identity (system-assigned or user-assigned). ConnectionString is not required; AccountName is.

"DevelopmentHelpers": {
  "AzureConfiguration": {
    "AccountName": "<your-storage-account-name>",
    "AuthMode": "ManagedIdentity"
  }
}

AuthMode: UserToken (client credentials)

Use an Azure AD application (client credentials) to access storage via RBAC:

"DevelopmentHelpers": {
  "AzureConfiguration": {
    "AccountName": "<your-storage-account-name>",
    "AuthMode": "UserToken",
    "TenantId": "<your-tenant-id>",
    "ClientId": "<your-client-id>",
    "ClientSecret": "<your-client-secret>"
  }
}

Note: AuthMode can also be omitted; in that case AzureConfiguration will infer DevelopmentStorage when ConnectionString contains UseDevelopmentStorage=true, otherwise it will default to ConnectionString.

Registering services (dependency injection)

The core DI extension methods are defined in DependencyInjection.cs.

1. Register using IConfiguration

This reads the DevelopmentHelpers:AzureConfiguration section and registers IStorage with AzureStorage:

// in Program.cs / Startup.cs
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAzureBlobStorage(builder.Configuration); // registers IStorage
builder.Services.AddAzureFileStorage(builder.Configuration); // registers IAzureFileStorage

var app = builder.Build();

You can also use the legacy combined registration if you want both IStorage and IAzureFileStorage from a single call:

builder.Services.AddAzureStorage(builder.Configuration);

2. Register using a connection string (blob only)

When you have a connection string at runtime (env var, secret store, etc.):

var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration["StorageAccountConnectionString"]; // or any source

builder.Services.AddAzureBlobStorage(new AzureConfiguration
{
    ConnectionString = connectionString,
    AuthMode = AzureAuthMode.ConnectionString
});

var app = builder.Build();

3. Register using a strongly-typed AzureConfiguration

This is useful in tests or when you build config in code:

var azureConfig = new AzureConfiguration
{
    ConnectionString = "UseDevelopmentStorage=true",
    AuthMode = AzureAuthMode.DevelopmentStorage
};

builder.Services.AddAzureBlobStorage(azureConfig);

For managed identity:

var azureConfig = new AzureConfiguration
{
    AccountName = "mystorageaccount",
    AuthMode = AzureAuthMode.ManagedIdentity
};

builder.Services.AddAzureBlobStorage(azureConfig);

For user token:

var azureConfig = new AzureConfiguration
{
    AccountName = "mystorageaccount",
    AuthMode = AzureAuthMode.UserToken,
    TenantId = "<tenant-id>",
    ClientId = "<client-id>",
    ClientSecret = "<client-secret>"
};

builder.Services.AddAzureBlobStorage(azureConfig);

4. Register Azure File Storage

Using configuration:

builder.Services.AddAzureFileStorage(builder.Configuration);

Using explicit values:

var fileStorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net";
var shareName = "my-share";

builder.Services.AddAzureFileStorage(fileStorageConnectionString, shareName);

Basic usage examples

Create storage instances (examples)

// Using DI (recommended)
public class MyService
{
    private readonly IStorage _storage;
    private readonly IAzureFileStorage _fileStorage;

    public MyService(IStorage storage, IAzureFileStorage fileStorage)
    {
        _storage = storage;
        _fileStorage = fileStorage;
    }
}

// Or instantiate manually for quick testing
var azureConfig = new AzureConfiguration
{
    ConnectionString = "UseDevelopmentStorage=true",
    AuthMode = AzureAuthMode.DevelopmentStorage
};
var logger = loggerFactory.CreateLogger<AzureStorage>();
IStorage storage = new AzureStorage(azureConfig, logger);

Uploading and downloading

// Upload a single file
var fileInfo = new FileInfo("/path/to/file.txt");
var blobUrl = await _storage.UploadFileAsync(fileInfo, MimeTypes.txt, "my-container");

// Upload a Directory
await _storage.UploadDirectoryAsync(new DirectoryInfo("/path/to/folder"), "my-container");

// Download a file (by blob URL)
var downloaded = await _storage.DownloadToFileAsync(blobUrl, "/local/download/path");

// Download entire container to local folder
await _storage.DownloadContainer("my-container", "/local/download/path");

// Create a zip from a container
var zipPath = await _storage.CreateZipFromContainerAsync("my-container", "/tmp", "archive.zip");

Chunked uploads (large files)

// Upload large file in chunks
var uri = await _storage.UploadInChunks(fullFilePath, "container-name", "file-name.txt", MimeTypes.txt);

Checking blobs and containers

// Check existence
bool exists = await _storage.BlobExistsAsync(blobUrl);

// Create a container if not exists
var response = await _storage.CreateContainerAsync("container-name", publicAccess: false);

// List containers
var containers = await _storage.GetContainersAsync();

Sync helpers

The library includes helpers for synchronizing between containers or from a directory to a container.

// Container to container sync
var syncHelper = new ContainerToContainerSyncHelper(sourceStorage, targetStorage);
var (success, message) = await syncHelper.SyncSourceToTargetContainersAsync("source", "target", deleteExtraFiles: false, localTempPath: "/tmp");

// Directory to container sync helper
var directorySyncHelper = new DirectoryToContainerSyncHelper(storage);
var (blobUrls, _) = await directorySyncHelper.GetBlobUrlListExistInTargetButNotInSourceAsync(sourceDirectoryPath, "target-container");

Tips and best practices

  • Use UploadInChunks for large files to avoid memory issues.
  • Keep container names lowercase when interacting with Azure Blob Storage.
  • When uploading directories with nested folders, use consistent path separators (/) for blob names.
  • Clean up temporary local directories after operations to avoid consuming disk space.
  • Prefer managed identities or AAD-based UserToken mode over account keys for production deployments.

Testing

The DevelopmentHelpers.Storage.Core.Tests project includes integration tests for all authentication modes (DevelopmentStorage, ConnectionString, ManagedIdentity, UserToken) using per-mode appsettings.*.json files in the test project. These tests exercise common flows such as uploading/downloading files, chunked uploads, container sync and zip creation.

Contributing

Contributions and issues are welcome. Please open an issue describing the problem or the feature request and submit pull requests for fixes.

License

Include your license information here (e.g., MIT) or a note about internal use.

If you need a targeted example or the exact code snippet for a specific scenario, describe the scenario and I will add a short sample.

Product Compatible and additional computed target framework versions.
.NET 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
11.0.0 194 12/24/2025
10.0.5 176 12/22/2025
10.0.4 177 12/22/2025
10.0.3 175 12/22/2025
10.0.2 171 12/22/2025
10.0.1 287 12/16/2025
10.0.0 217 12/3/2025
9.0.8 189 9/26/2025
9.0.6 287 8/27/2025
9.0.5 292 8/8/2025
9.0.4 309 5/20/2025
9.0.3 346 5/13/2025
9.0.2 254 4/22/2025
9.0.1 249 4/6/2025
9.0.0 312 11/20/2024
7.0.19 206 11/14/2024
7.0.18 454 10/11/2024
7.0.17 210 10/9/2024
7.0.16 224 9/30/2024
7.0.15 300 8/13/2024
7.0.14 232 8/2/2024
7.0.11 211 5/31/2024
7.0.10 209 5/23/2024
7.0.9 201 5/23/2024
7.0.8 377 4/10/2024
7.0.7 404 2/16/2024
7.0.6 232 2/7/2024
7.0.5 214 1/29/2024
7.0.4 224 1/16/2024
7.0.3 253 12/26/2023
7.0.2 246 12/15/2023
7.0.1 223 12/15/2023
7.0.0 261 11/14/2023
6.0.5 263 10/23/2023
6.0.4 330 8/2/2023
6.0.3 233 7/27/2023
6.0.2 256 7/11/2023
6.0.1 259 6/22/2023
6.0.0 295 5/4/2023
5.0.3 307 4/27/2023
5.0.2 341 4/11/2023
5.0.1 384 2/22/2023
5.0.0 510 11/10/2022
4.0.11 456 11/10/2022
4.0.10 448 11/10/2022
4.0.9 591 9/6/2022
4.0.8 643 7/25/2022
4.0.7 565 7/25/2022
4.0.6 567 7/25/2022
4.0.5 604 7/14/2022
4.0.4 268 7/14/2022
4.0.3 704 3/24/2022
4.0.2 329 12/16/2021
4.0.1 300 12/16/2021
4.0.0 1,041 11/29/2021
3.0.3 777 10/15/2020
3.0.2 653 9/30/2020
3.0.1 624 9/29/2020
3.0.0 670 9/16/2020
2.0.2 798 7/8/2020
2.0.1 775 12/25/2019
2.0.0 713 12/25/2019
1.0.6 736 12/5/2019
1.0.5 846 6/2/2019
1.0.4 945 11/30/2018
1.0.3 972 11/12/2018
1.0.2 966 11/12/2018
1.0.1 967 11/12/2018
1.0.0 966 11/12/2018

Major Update: Version 11.0.0 introduces significant enhancements and new features to improve functionality and user experience.
- Enhanced Performance: Optimized algorithms for faster upload and download operations.
- New Features: Added support for additional Azure Storage features and improved error handling.
- Added Support to use Development Storage, ConnectionString, TokenCredential, or Managed Identity for Azure Storage.
- Bug Fixes: Resolved several issues reported in the previous version to ensure stability.