DevelopmentHelpers.Storage.Core 10.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package DevelopmentHelpers.Storage.Core --version 10.0.3
                    
NuGet\Install-Package DevelopmentHelpers.Storage.Core -Version 10.0.3
                    
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="10.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevelopmentHelpers.Storage.Core" Version="10.0.3" />
                    
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 10.0.3
                    
#r "nuget: DevelopmentHelpers.Storage.Core, 10.0.3"
                    
#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@10.0.3
                    
#: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=10.0.3
                    
Install as a Cake Addin
#tool nuget:?package=DevelopmentHelpers.Storage.Core&version=10.0.3
                    
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.

Prerequisites

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

Quick start

  1. Add the project or NuGet package to your solution.
  2. Configure storage settings in appsettings.json (example below).
  3. Register services in Program.cs / Startup.cs.
  4. Inject IStorage or IAzureFileStorage where needed and call methods.

Configuration (appsettings.json)

Keep the following structure in your appsettings.json under a DevelopmentHelpers section. The values shown are examples — replace them with your account details.

"DevelopmentHelpers": {
  "AzureConfiguration": {
    "AccountName": "Account-Name",
    "AccountKey": "Account-Key",
    "UseHttps": "True"
  },
  "AzureFileStorageConfiguration": {
    "ConnectionString": "Connection-String",
    "ShareName": "Share-Name"
  }
}

Registering services (dependency injection)

  1. In Program.cs or Startup.cs register the library services so you can resolve IStorage and IAzureFileStorage from DI. The library exposes an extension method to register required services.
// in Program.cs
services.AddAzureStorage(Configuration);

Note: AddAzureStorage reads the DevelopmentHelpers section from configuration and registers the appropriate implementations.

Registering services using a connection string (no appsettings.json required)

New overloads of the DevelopmentHelpersStorageExtensions allow registering storage services by passing a connection string directly. This is useful when you don't want to rely on IConfiguration or when the connection string is obtained at runtime (environment variable, secret store, etc.).

// Example: register using a full Azure Storage connection string
var connectionString = "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net";

// Register both blob and file storage implementations using the connection string
services.AddAzureStorage(connectionString);

// If you only need blob or file storage, use the specific overloads (if available):
// services.AddAzureBlobStorage(connectionString);
// services.AddAzureFileStorage(connectionString, shareName: "my-share");
  1. Register Services in Program.cs
    var builder = WebApplication.CreateBuilder(args);

    // Add Azure Blob Storage (IStorage)
    builder.Services.AddAzureBlobStorage(builder.Configuration);

    // Add Azure File Storage (IAzureFileStorage)
    builder.Services.AddAzureFileStorage(builder.Configuration);

    var app = builder.Build();

  1. Register Using Connection String for both Blob and File Storage
    var builder = WebApplication.CreateBuilder(args);
    var connectionString = "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net";
    // Add Azure Blob and File Storage using connection string
    builder.Services.AddAzureStorage(connectionString);
    var app = builder.Build();
  1. Register Using Connection String for Blob Storage Only
    var builder = WebApplication.CreateBuilder(args);
    var connectionString = "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net";
    // Add Azure Blob Storage using connection string
    builder.Services.AddAzureBlobStorage(connectionString);
    var app = builder.Build();
  1. Register Using Strongly Typed Configuration Objects
    var azureConfig = new AzureConfiguration
    {
        AccountName = "devstoreaccount1",
        AccountKey = "...",
        UseHttps = false,
        AllowPublicAccess = false
    };

builder.Services.AddAzureBlobStorage(azureConfig);

These overloads will internally parse the connection string and initialize AzureConfiguration and AzureFileStorageConfiguration equivalents so the library components are ready to use without any JSON configuration.

Advanced registration using options

If you need to customize settings, there are also overloads that accept option builders:

services.AddAzureStorage(options =>
{
    options.ConnectionString = connectionString;
    options.FileShareName = "my-share"; // when relevant
    // other option properties as exposed by the library
});

Notes:

  • Using connection strings is convenient for ephemeral or CI scenarios; prefer managed identities or secure secrets stores in production when possible.
  • The connection-string-based registration behaves equivalently to the configuration-based registration; only the initialization source differs.

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 Models.AzureConfiguration
{
    AccountName = "...",
    AccountKey = "...",
    UseHttps = true
};
var logger = ConfigHelper.Instance.LoggerFactory.CreateLogger<AzureStorage>();
IStorage storage = new AzureStorage(azureConfig, logger);
IStorage localStorage = new FileSystemStorage(azureConfig /* or local config */, logger);
IAzureFileStorage fileStorage = new AzureFileStorage(/* AzureFileStorageConfiguration */, 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.SyncContainersAsync("source", "target", deleteExtraFiles: false, localTempPath: "/tmp");

// Directory to container sync helper
var directorySyncHelper = new DirectoryToContainerSyncHelper(storage);
var result = 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.

Testing

The DevelopmentHelpers.Storage.Core.Tests project includes a comprehensive set of integration tests that exercise common flows such as uploading/downloading files, chunked uploads, container sync and zip creation. The tests expect an Azure Storage account configured via ConfigHelper in test settings. You can inspect the test project for sample usage patterns.

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 299 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 294 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 590 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

Added Support for Development Storage Emulator in Azure Storage interactions.