ManagedCode.Storage.Azure
2.1.17
Prefix Reserved
See the version list below for details.
dotnet add package ManagedCode.Storage.Azure --version 2.1.17
NuGet\Install-Package ManagedCode.Storage.Azure -Version 2.1.17
<PackageReference Include="ManagedCode.Storage.Azure" Version="2.1.17" />
paket add ManagedCode.Storage.Azure --version 2.1.17
#r "nuget: ManagedCode.Storage.Azure, 2.1.17"
// Install ManagedCode.Storage.Azure as a Cake Addin #addin nuget:?package=ManagedCode.Storage.Azure&version=2.1.17 // Install ManagedCode.Storage.Azure as a Cake Tool #tool nuget:?package=ManagedCode.Storage.Azure&version=2.1.17
ManagedCode.Storage
Version | Package | Description |
---|---|---|
ManagedCode.Storage.Core | Core | |
ManagedCode.Storage.FileSystem | FileSystem | |
ManagedCode.Storage.Azure | Azure | |
ManagedCode.Storage.Aws | AWS | |
ManagedCode.Storage.Gcp | GCP | |
ManagedCode.Storage.AspNetExtensions | AspNetExtensions |
Storage
General concept
One of the key benefits of using a universal wrapper for cloud blob storages is that it provides a consistent, easy-to-use interface for working with different types of blob storage. This can make it much easier for developers to switch between different storage providers, or to use multiple providers in the same project.
A universal wrapper can also simplify the development process by providing a single set of methods for working with blob storage, rather than requiring developers to learn and use the different APIs provided by each storage provider. This can save time and reduce the complexity of the code, making it easier to write, maintain, and debug.
In addition, a universal wrapper can provide additional functionality that is not available through the individual storage providers, such as support for common patterns like asynchronous programming and error handling. This can make it easier to write high-quality, reliable code that is robust and resilient to errors.
Overall, using a universal wrapper for cloud blob storages can provide many benefits, including improved flexibility, simplicity, and reliability in your application. A universal storage for working with multiple storage providers:
- Azure
- Google Cloud
- Amazon
- FileSystem
Motivation
Cloud storage is a popular and convenient way to store and access data in the cloud. However, different cloud storage providers often have their own unique APIs and interfaces for accessing and manipulating data. This can make it difficult to switch between different providers or to use multiple providers simultaneously.
Our library, provides a universal interface for accessing and manipulating data in different cloud blob storage providers. This makes it easy to switch between providers or to use multiple providers at the same time, without having to learn and use multiple APIs.
Features
- Provides a universal interface for accessing and manipulating data in different cloud blob storage providers.
- Makes it easy to switch between providers or to use multiple providers simultaneously.
- Supports common operations such as uploading, downloading, and deleting data.
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
Conclusion
In summary, Storage library provides a universal interface for accessing and manipulating data in different cloud blob storage providers. It makes it easy to switch between providers or to use multiple providers simultaneously, without having to learn and use multiple APIs. We hope you find it useful in your own projects!
Product | Versions 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. |
-
net8.0
- Azure.Identity (>= 1.11.3)
- Azure.Storage.Blobs (>= 12.20.0)
- Humanizer.Core (>= 2.14.1)
- ManagedCode.Communication (>= 8.0.1)
- ManagedCode.Storage.Core (>= 2.1.17)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- System.Linq.Async (>= 6.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ManagedCode.Storage.Azure:
Package | Downloads |
---|---|
ManagedCode.Storage.TestFakes
Fake implementaions for units tests |
|
ManagedCode.ZoneTree.BlobFileSystem
Azure Blob FileSystem for ZoneTree |
|
ManagedCode.Lucene.CloudDirectory
CloudDirectory for Lucene.NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.21 | 339 | 7/31/2024 |
2.1.20 | 134 | 7/13/2024 |
2.1.19 | 139 | 6/14/2024 |
2.1.18 | 124 | 6/13/2024 |
2.1.17 | 105 | 6/12/2024 |
2.1.16 | 123 | 6/2/2024 |
2.1.15-alpha | 173 | 5/22/2023 |
2.1.14 | 2,251 | 5/21/2023 |
2.1.13 | 6,042 | 12/20/2022 |
2.1.11 | 1,532 | 10/18/2022 |
2.1.10 | 490 | 10/18/2022 |
2.1.9 | 497 | 10/18/2022 |
2.1.8 | 507 | 10/18/2022 |
2.1.7 | 501 | 10/18/2022 |
2.1.6 | 501 | 10/18/2022 |
2.1.5 | 477 | 10/17/2022 |
2.1.4 | 499 | 10/17/2022 |
2.1.3 | 517 | 10/17/2022 |
2.1.2 | 505 | 10/16/2022 |
2.1.1 | 499 | 10/16/2022 |
2.1.0 | 508 | 10/14/2022 |
2.0.18 | 409 | 10/14/2022 |
2.0.11 | 3,056 | 8/12/2022 |
2.0.10 | 395 | 8/12/2022 |
2.0.9 | 409 | 8/11/2022 |
2.0.8 | 433 | 8/10/2022 |
2.0.7 | 414 | 8/9/2022 |
2.0.6 | 430 | 8/9/2022 |
2.0.5 | 437 | 8/8/2022 |
2.0.4 | 434 | 7/27/2022 |
2.0.3 | 424 | 7/26/2022 |
2.0.2 | 417 | 7/25/2022 |
2.0.1 | 469 | 7/22/2022 |
2.0.0 | 419 | 7/22/2022 |
1.2.1 | 465 | 7/17/2022 |
1.2.0 | 2,618 | 4/19/2022 |
1.1.2 | 411 | 4/18/2022 |
1.1.1 | 774 | 4/7/2022 |
1.1.0 | 433 | 3/29/2022 |
1.0.0 | 435 | 3/23/2022 |
0.1.0 | 439 | 3/22/2022 |
0.0.1 | 426 | 3/21/2022 |