Centeva.ObjectStorage.Azure.Blob 7.1.0-beta.1

Prefix Reserved
This is a prerelease version of Centeva.ObjectStorage.Azure.Blob.
dotnet add package Centeva.ObjectStorage.Azure.Blob --version 7.1.0-beta.1
                    
NuGet\Install-Package Centeva.ObjectStorage.Azure.Blob -Version 7.1.0-beta.1
                    
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="Centeva.ObjectStorage.Azure.Blob" Version="7.1.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Centeva.ObjectStorage.Azure.Blob" Version="7.1.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="Centeva.ObjectStorage.Azure.Blob" />
                    
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 Centeva.ObjectStorage.Azure.Blob --version 7.1.0-beta.1
                    
#r "nuget: Centeva.ObjectStorage.Azure.Blob, 7.1.0-beta.1"
                    
#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 Centeva.ObjectStorage.Azure.Blob@7.1.0-beta.1
                    
#: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=Centeva.ObjectStorage.Azure.Blob&version=7.1.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Centeva.ObjectStorage.Azure.Blob&version=7.1.0-beta.1&prerelease
                    
Install as a Cake Tool

Centeva Object Storage Library

Centeva.ObjectStorage is a .NET 8 and .NET Standard 2.0 library that provides a generic interface to local or cloud-hosted object ("blob") storage providers.

Supported providers are:

  • Amazon AWS S3 (and anything compatible with its API such as MinIO)
  • Google Cloud Storage
  • Azure Blob Storage
  • Azure Files
  • Local disk

Built With

Getting Started

Import the Centeva.ObjectStorage package to your projects where needed, along with the desired provider sub-packages:

  • Centeva.ObjectStorage.GCP
  • Centeva.ObjectStorage.AWS
  • Centeva.ObjectStorage.Azure.Blob
  • Centeva.ObjectStorage.Azure.File

Create an instance of StorageFactory and register the providers you require, then build an instance of IObjectStorage using a connection string:

var factory = new StorageFactory()
    .UseAwsS3Storage()
    .UseAzureBlobStorage()
    .UseAzureFileStorage()
    .UseGoogleCloudStorage();

var storage = factory.CreateConnection("provider://key1=value1;key2=value2");

In modern .NET applications, you will likely do this as part of service registration in Program.cs, obtaining the connection string from configuration. See Dependency Injection for extension methods that handle this for you.

In some cases you may prefer to instantiate storage providers directly rather than using connection strings. Each provider's constructor allows the needed parameters to be provided.

Examples

// Local Disk
var diskFromConnectionString = factory.CreateConnection("disk://path=C:\\temp\\files");
var diskFromConstructor = new DiskObjectStorage("C:\\temp\\files");

// AWS S3
var s3FromConnectionString = factory.CreateConnection("aws.s3://bucket=myfiles;accessKey=mykey;secretKey=secret");
var s3FromConstructor = new AwsS3ObjectStorage("myfiles", "regionName", "endpointUrl", "accessKey", "secret");

// Azure Blob Storage
var blobFromConnectionString = factory.CreateConnection("azure.blob://container=myfiles;accountName=myaccount;accountKey=myAccountKey");
var blobFromConstructor = new AzureBlobObjectStorage("accountName", "accountKey", "containerName");

// Azure Files
var fileFromConnectionString = factory.CreateConnection("azure.file://share=myfiles;accountName=myaccount;accountKey=myAccountKey");
var fileFromConstructor = new AzureFileStorage("accountName", "accountKey", "shareName");

// Google Cloud Storage
var googleFromConnectionString = factory.CreateConnection("google.storage://bucket=myfiles;credentialsFilePath=/path/to/creds.json");
var googleFromConnectionString2 = factory.CreateConnection("google.storage://bucket=myfiles;credentials=base64EncodedCredentialsJson");
var googleFromConstructor = GoogleObjectStorage.CreateFromCredentialsFile("bucketName", "/path/to/creds.json");
var googleFromConstructor2 = GoogleObjectStorage.CreateFromCredentialsJson("bucketName", "credentialsJsonString");

// MinIO (using AWS S3 provider)
var minioFromConnectionString = factory.CreateConnection("aws.s3://endpoint=http://localhost:9000;region=us-east-1;bucket=myfiles;accessKey=myAccount;secretKey=myPassword");
var minioFromConstructor = new AwsS3ObjectStorage("myfiles", "us-east-1", "http://localhost:9000", "myAccount", "myPassword");

Dependency Injection

The AddObjectStorage extension method registers an IObjectStorage singleton with the built-in .NET dependency injection container:

builder.Services.AddObjectStorage(config => config
    .UseAwsS3Storage()
    .UseAzureBlobStorage()
    .UseAzureFileStorage()
    .UseGoogleCloudStorage()
    .UseConnectionString(builder.Configuration.GetConnectionString("ObjectStorage")!));

Providers can also be configured directly, without a connection string:

// AWS S3
builder.Services.AddObjectStorage(config =>
    config.UseAwsS3Storage("myfiles", "us-east-1", null, "accessKey", "secret"));

// Azure Blob Storage
builder.Services.AddObjectStorage(config =>
    config.UseAzureBlobStorage("accountName", "accountKey", "containerName"));

builder.Services.AddObjectStorage(config =>
    config.UseAzureBlobStorage("accountName", "containerName", new DefaultAzureCredential()));

// Azure Files
builder.Services.AddObjectStorage(config =>
    config.UseAzureFileStorage("accountName", "accountKey", "shareName"));

builder.Services.AddObjectStorage(config =>
    config.UseAzureFileStorage("accountName", "shareName", new DefaultAzureCredential()));

// Google Cloud Storage
builder.Services.AddObjectStorage(config =>
    config.UseGoogleCloudStorageFromCredentialsFile("bucketName", "/path/to/creds.json"));

builder.Services.AddObjectStorage(config =>
    config.UseGoogleCloudStorageFromCredentialsJson("bucketName", credentialsJsonString));

You can also supply any IObjectStorage instance you have constructed yourself:

builder.Services.AddObjectStorage(config =>
    config.UseStorage(new DiskObjectStorage(@"C:\temp\files")));

Then inject IObjectStorage where you need it:

public class MyService(IObjectStorage storage)
{
    public Task<bool> ExistsAsync(StoragePath path) => storage.ExistsAsync(path);
}

If the configured provider supports optional capabilities, the corresponding interfaces are registered against the same instance, so you can inject them directly:

public class MyService(ISupportsSignedUrls signedUrls)
{
    public Task<Uri> GetUrlAsync(StoragePath path) => signedUrls.GetDownloadUrlAsync(path);
}

ISupportsSignedUrls and ISupportsMetadata are only registered when the provider actually implements them.

If your application needs more than one storage configuration, register them as keyed services:

builder.Services.AddKeyedObjectStorage("documents", config => config
    .UseAwsS3Storage()
    .UseConnectionString(builder.Configuration.GetConnectionString("Documents")!));

builder.Services.AddKeyedObjectStorage("thumbnails", config => config
    .UseAzureBlobStorage()
    .UseConnectionString(builder.Configuration.GetConnectionString("Thumbnails")!));

Then resolve them by key:

public class MyService([FromKeyedServices("documents")] IObjectStorage storage)
{
    public Task<bool> ExistsAsync(StoragePath path) => storage.ExistsAsync(path);
}

Capability interfaces are registered with the same key.

If the connection string isn't known until runtime -- for example, in a multi-tenant application where each tenant has its own storage configuration -- register an IObjectStorageFactory instead. It resolves connections from a connection string on demand rather than building a single instance at startup:

builder.Services.AddObjectStorageFactory(config => config
    .UseAwsS3Storage()
    .UseAzureBlobStorage()
    .UseAzureFileStorage()
    .UseGoogleCloudStorage());
public class MyService(IObjectStorageFactory storageFactory)
{
    public Task<bool> ExistsAsync(string tenantConnectionString, StoragePath path) =>
        storageFactory.CreateConnection(tenantConnectionString).ExistsAsync(path);
}

IObjectStorageFactory doesn't register capability interfaces, since each call to CreateConnection can return a different provider; check for them with an is pattern (e.g. storage is ISupportsSignedUrls) after resolving a connection.

MinIO and macOS Compatibility

When using MinIO or other S3-compatible storage services with custom endpoints on macOS, the library automatically uses AuthenticationRegion instead of RegionEndpoint to avoid DNS resolution conflicts with the AWS SDK. This ensures proper functionality across all platforms (Windows, Linux, and macOS) without requiring any special configuration.

TODO: Write API documentation

Contributing

Please use a Pull Request to suggest changes to this library. As this is a shared library, strict semantic versioning rules should be followed to avoid unexpected breaking changes.

Running Tests

Use the dotnet test command, or your Visual Studio Test Explorer. The cloud provider integration tests require configuration and credentials for each of the cloud providers - you can set those via User Secrets or environment variables. Bucket, container, and share names are already set in testsettings.json; only the credentials need to be supplied.

Adding a New Storage Provider

A provider needs an IConnectionFactory that builds an IObjectStorage from a parsed connection string (returning null if it doesn't recognize the provider name), plus a StorageFactoryExtensions class with a UseXStorage() registration method:

public static class StorageFactoryExtensions
{
    public static TRegistry UseXStorage<TRegistry>(this TRegistry registry)
        where TRegistry : IObjectStorageProviderRegistry
    {
        registry.Register(new XConnectionFactory());

        return registry;
    }
}

Keep it generic over TRegistry : IObjectStorageProviderRegistry exactly as shown -- a non-generic version compiles but silently breaks chaining into AddObjectStorage's UseConnectionString/UseStorage (see IObjectStorageProviderRegistry's doc comment for why). Add a test to ProviderRegistrationTests.cs exercising the same chain -- no live credentials needed, since a regression here is a compile error, not a runtime one.

If the provider also supports configuring storage directly, without a connection string, add an overload targeting ObjectStorageBuilder specifically (see the existing providers' StorageFactoryExtensions for examples) -- it doesn't need to be generic, since ObjectStorageBuilder is already the most-derived type in the hierarchy.

Deployment

This library is versioned by GitVersion. Create a Git tag for an official release (e.g., "v1.0.0"). Version numbers can be incremented via commit message using the GitVersion approaches.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
7.1.0-beta.1 35 9/23/2026
7.0.0 652 12/23/2025
6.2.0 284 10/30/2025
6.1.0 373 9/17/2025
6.0.0 324 8/20/2025
5.1.0 234 8/20/2025
5.1.0-tags-v5-1-0-pre-3.1 132 2/27/2025
5.1.0-tags-v5-1-0-pre-2.1 329 1/23/2025
5.1.0-tags-v5-1-0-pre-1.1 119 1/22/2025
5.0.1 243 1/17/2025
5.0.0 215 12/19/2024
5.0.0-tags-v5-0-0-pre-1.1 141 11/15/2024
4.0.0 217 10/21/2024
3.1.0 204 10/9/2024
3.0.0 211 9/26/2024
3.0.0-tags-v3-0-0-pre-4.1 148 9/26/2024
3.0.0-tags-v3-0-0-pre-3.1 133 9/26/2024
3.0.0-tags-v3-0-0-pre-2.1 137 9/26/2024
Loading failed