ManagedCode.Storage.AzureDataLake 2.1.11

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
.NET 6.0
dotnet add package ManagedCode.Storage.AzureDataLake --version 2.1.11
NuGet\Install-Package ManagedCode.Storage.AzureDataLake -Version 2.1.11
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="ManagedCode.Storage.AzureDataLake" Version="2.1.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ManagedCode.Storage.AzureDataLake --version 2.1.11
#r "nuget: ManagedCode.Storage.AzureDataLake, 2.1.11"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ManagedCode.Storage.AzureDataLake as a Cake Addin
#addin nuget:?package=ManagedCode.Storage.AzureDataLake&version=2.1.11

// Install ManagedCode.Storage.AzureDataLake as a Cake Tool
#tool nuget:?package=ManagedCode.Storage.AzureDataLake&version=2.1.11

img|300x200

ManagedCode.Storage

.NET Coverage Status nuget CodeQL

Version Package Description
NuGet Package ManagedCode.Storage.Core Core
NuGet Package ManagedCode.Storage.FileSystem FileSystem
NuGet Package ManagedCode.Storage.Azure Azure
NuGet Package ManagedCode.Storage.Aws AWS
NuGet Package ManagedCode.Storage.Gcp GCP
NuGet Package ManagedCode.Storage.AspNetExtensions AspNetExtensions

Storage


Storage pattern implementation for C#.

A universal storage for working with multiple storage providers:

  • Azure
  • Google Cloud
  • Amazon
  • FileSystem

General concept

The library incapsulates all provider specific to make connection and managing storages as easy as possible. You have as customer just connect the library in your Startup providing necessary connection strings and inject needed interfaces in your services.

Connection modes

You can connect storage interface in two modes provider-specific and default. In case of default you are restricted with one storage type

Azure

Default mode connection:

// Startup.cs
services.AddAzureStorageAsDefault(new AzureStorageOptions
{
    Container = "{YOUR_CONTAINER_NAME}",
    ConnectionString = "{YOUR_CONNECTION_NAME}",
});

Using in default mode:

// MyService.cs
public class MyService
{
    private readonly IStorage _storage;

    public MyService(IStorage storage)
    {
        _storage = storage;
    }
}

Provider-specific mode connection:

// Startup.cs
services.AddAzureStorage(new AzureStorageOptions
{
    Container = "{YOUR_CONTAINER_NAME}",
    ConnectionString = "{YOUR_CONNECTION_NAME}",
});

Using in provider-specific mode

// MyService.cs
public class MyService
{
    private readonly IAzureStorage _azureStorage;

    public MyService(IAzureStorage azureStorage)
    {
        _azureStorage = azureStorage;
    }
}

<details> <summary>Google Cloud (Click here to expand)</summary>

Google Cloud

Default mode connection:

// Startup.cs
services.AddGCPStorageAsDefault(opt =>
{
    opt.GoogleCredential = GoogleCredential.FromFile("{PATH_TO_YOUR_CREDENTIALS_FILE}.json");

    opt.BucketOptions = new BucketOptions()
    {
        ProjectId = "{YOUR_API_PROJECT_ID}",
        Bucket = "{YOUR_BUCKET_NAME}",
    };
});

Using in default mode:

// MyService.cs
public class MyService
{
    private readonly IStorage _storage;
  
    public MyService(IStorage storage)
    {
        _storage = storage;
    }
}

Provider-specific mode connection:

// Startup.cs
services.AddGCPStorage(new GCPStorageOptions
{
    BucketOptions = new BucketOptions()
    {
        ProjectId = "{YOUR_API_PROJECT_ID}",
        Bucket = "{YOUR_BUCKET_NAME}",
    }
});

Using in provider-specific mode

// MyService.cs
public class MyService
{
    private readonly IGCPStorage _gcpStorage;
    public MyService(IGCPStorage gcpStorage)
    {
        _gcpStorage = gcpStorage;
    }
}

</details>

<details> <summary>Amazon (Click here to expand)</summary>

Amazon

Default mode connection:

// Startup.cs
//aws libarary overwrites property values. you should only create configurations this way. 
var awsConfig = new AmazonS3Config();
awsConfig.RegionEndpoint = RegionEndpoint.EUWest1;
awsConfig.ForcePathStyle = true;
awsConfig.UseHttp = true;
awsConfig.ServiceURL = "http://localhost:4566"; //this is the default port for the aws s3 emulator, must be last in the list

services.AddAWSStorageAsDefault(opt =>
{
    opt.PublicKey = "{YOUR_PUBLIC_KEY}";
    opt.SecretKey = "{YOUR_SECRET_KEY}";
    opt.Bucket = "{YOUR_BUCKET_NAME}";
    opt.OriginalOptions = awsConfig;
});

Using in default mode:

// MyService.cs
public class MyService
{
    private readonly IStorage _storage;
  
    public MyService(IStorage storage)
    {
        _storage = storage;
    }
}

Provider-specific mode connection:

// Startup.cs
services.AddAWSStorage(new AWSStorageOptions
{
    PublicKey = "{YOUR_PUBLIC_KEY}",
    SecretKey = "{YOUR_SECRET_KEY}",
    Bucket = "{YOUR_BUCKET_NAME}",
    OriginalOptions = awsConfig
});

Using in provider-specific mode

// MyService.cs
public class MyService
{
    private readonly IAWSStorage _gcpStorage;
    public MyService(IAWSStorage gcpStorage)
    {
        _gcpStorage = gcpStorage;
    }
}

</details>

<details> <summary>FileSystem (Click here to expand)</summary>

FileSystem

Default mode connection:

// Startup.cs
services.AddFileSystemStorageAsDefault(opt =>
{
    opt.BaseFolder = Path.Combine(Environment.CurrentDirectory, "{YOUR_BUCKET_NAME}");
});

Using in default mode:

// MyService.cs
public class MyService
{
    private readonly IStorage _storage;
  
    public MyService(IStorage storage)
    {
        _storage = storage;
    }
}

Provider-specific mode connection:

// Startup.cs
services.AddFileSystemStorage(new FileSystemStorageOptions
{
    BaseFolder = Path.Combine(Environment.CurrentDirectory, "{YOUR_BUCKET_NAME}"),
});

Using in provider-specific mode

// MyService.cs
public class MyService
{
    private readonly IFileSystemStorage _fileSystemStorage;
    public MyService(IFileSystemStorage fileSystemStorage)
    {
        _fileSystemStorage = fileSystemStorage;
    }
}

</details>

How to use

We assume that below code snippets are placed in your service class with injected IStorage:

public class MyService
{
    private readonly IStorage _storage;
    public MyService(IStorage storage)
    {
        _storage = storage;
    }
}

Upload

await _storage.UploadAsync(new Stream());
await _storage.UploadAsync("some string content");
await _storage.UploadAsync(new FileInfo("D:\\my_report.txt"));

Delete

await _storage.DeleteAsync("my_report.txt");

Download

var localFile = await _storage.DownloadAsync("my_report.txt");

Get metadata

await _storage.GetBlobMetadataAsync("my_report.txt");

Native client

If you need more flexibility, you can use native client for any IStorage<T>

_storage.StorageClient
Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ManagedCode.Storage.AzureDataLake:

Package Downloads
ManagedCode.Storage.TestFakes The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Fake implementaions for units tests

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.11 185 10/18/2022
2.1.10 142 10/18/2022
2.1.9 146 10/18/2022
2.1.8 149 10/18/2022
2.1.7 143 10/18/2022
2.1.6 155 10/18/2022
2.1.5 151 10/17/2022
2.1.4 157 10/17/2022
2.1.3 159 10/17/2022
2.1.2 160 10/16/2022
2.1.1 160 10/16/2022
2.1.0 161 10/14/2022
2.0.18 123 10/14/2022
2.0.11 204 8/12/2022
2.0.10 134 8/12/2022
2.0.9 141 8/11/2022
2.0.8 161 8/10/2022
2.0.7 150 8/9/2022
2.0.6 154 8/9/2022
2.0.5 157 8/8/2022
2.0.4 176 7/27/2022
2.0.3 168 7/26/2022
2.0.2 153 7/25/2022
2.0.1 193 7/22/2022
2.0.0 153 7/22/2022
1.2.1 175 7/17/2022