ValiBlob.Azure
1.0.0
Error en el nombre del paquete.
dotnet add package ValiBlob.Azure --version 1.0.0
NuGet\Install-Package ValiBlob.Azure -Version 1.0.0
<PackageReference Include="ValiBlob.Azure" Version="1.0.0" />
<PackageVersion Include="ValiBlob.Azure" Version="1.0.0" />
<PackageReference Include="ValiBlob.Azure" />
paket add ValiBlob.Azure --version 1.0.0
#r "nuget: ValiBlob.Azure, 1.0.0"
#:package ValiBlob.Azure@1.0.0
#addin nuget:?package=ValiBlob.Azure&version=1.0.0
#tool nuget:?package=ValiBlob.Azure&version=1.0.0
Vali-Blob.Azure
Azure Blob Storage provider for Vali-Blob — the unified cloud storage abstraction library for .NET.
Implements IStorageProvider over Azure Blob Storage with SAS token presigned URLs, resumable block-blob uploads, optional automatic container creation, and seamless DI registration.
Compatibility
| Target Framework | Supported |
|---|---|
netstandard2.0 |
Yes |
netstandard2.1 |
Yes |
net6.0 |
Yes |
net7.0 |
Yes |
net8.0 |
Yes |
net9.0 |
Yes |
Installation
dotnet add package ValiBlob.Core
dotnet add package ValiBlob.Azure
Configuration
Using a connection string
{
"ValiBlob": {
"DefaultProvider": "Azure"
},
"ValiBlob:Azure": {
"Container": "my-files",
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net",
"CreateContainerIfNotExists": true
}
}
Using account name + key
{
"ValiBlob:Azure": {
"Container": "my-files",
"AccountName": "mystorageaccount",
"AccountKey": ""
}
}
Security: Never commit
AccountKeyorConnectionStringto source control. Use Azure Key Vault, environment variables, or Managed Identity instead.
Using Managed Identity (recommended for Azure-hosted apps)
{
"ValiBlob:Azure": {
"Container": "my-files",
"AccountName": "mystorageaccount"
}
}
When AccountKey is absent and no ConnectionString is set, the provider uses DefaultAzureCredential — which automatically picks up Managed Identity on App Service, AKS, and Azure VMs.
Registration
using ValiBlob.Core.DependencyInjection;
using ValiBlob.Azure.Extensions;
builder.Services
.AddValiBlob(opts => opts.DefaultProvider = "Azure")
.UseAzure();
With pipeline
builder.Services
.AddValiBlob(opts => opts.DefaultProvider = "Azure")
.UseAzure()
.WithPipeline(p => p
.UseValidation(v =>
{
v.AllowedExtensions = new[] { ".jpg", ".png", ".pdf", ".docx" };
v.MaxFileSizeBytes = 100 * 1024 * 1024; // 100 MB
})
.UseEncryption(e =>
{
e.Key = Convert.FromBase64String(builder.Configuration["Storage:Key"]!);
})
);
Usage
Upload
public class FileService(IStorageProvider storage)
{
public async Task<string> UploadAsync(IFormFile file)
{
await using var stream = file.OpenReadStream();
var result = await storage.UploadAsync(new UploadRequest
{
Path = StoragePath.From("uploads", file.FileName),
Content = stream,
ContentType = file.ContentType
});
if (!result.IsSuccess)
throw new Exception(result.ErrorMessage);
return result.Value!.Url;
}
}
Download
var result = await storage.DownloadAsync(new DownloadRequest
{
Path = StoragePath.From("uploads", "photo.jpg")
});
if (result.IsSuccess)
{
using var stream = result.Value!;
await stream.CopyToAsync(Response.Body);
}
Generate SAS presigned URL
// Download URL — valid for 30 minutes
var download = await storage.GetPresignedDownloadUrlAsync(new PresignedUrlRequest
{
Path = StoragePath.From("invoices", "invoice-001.pdf"),
ExpiresIn = TimeSpan.FromMinutes(30)
});
// Upload URL — client uploads directly to Azure
var upload = await storage.GetPresignedUploadUrlAsync(new PresignedUrlRequest
{
Path = StoragePath.From("uploads", "video.mp4"),
ExpiresIn = TimeSpan.FromMinutes(15)
});
Resumable upload
var session = await resumable.StartUploadAsync(new ResumableUploadRequest
{
FileName = "backup.zip",
ContentType = "application/zip",
TotalSize = totalBytes
});
// Upload chunks sequentially or with retry
foreach (var (chunk, index) in chunks.Select((c, i) => (c, i)))
{
await resumable.UploadChunkAsync(new ResumableChunkRequest
{
SessionId = session.SessionId,
ChunkIndex = index,
Data = chunk
});
}
await resumable.CompleteUploadAsync(session.SessionId);
Features
| Feature | Supported |
|---|---|
| Upload / Download / Delete / List | Yes |
| Exists check | Yes |
| Copy / Move | Yes |
| Presigned upload URL (SAS) | Yes |
| Presigned download URL (SAS) | Yes |
| Resumable chunked uploads | Yes |
| BucketOverride per request | Yes |
| Automatic container creation | Yes (opt-in) |
| Managed Identity | Yes |
| Custom metadata | Yes |
| Polly retry resilience | Yes |
Options reference
| Property | Default | Description |
|---|---|---|
Container |
— | Blob container name (required) |
ConnectionString |
— | Full Azure Storage connection string |
AccountName |
— | Storage account name (used with AccountKey or Managed Identity) |
AccountKey |
— | Storage account key |
CreateContainerIfNotExists |
false |
Auto-create the container on startup |
SasTokenExpiryMinutes |
60 |
Default expiry for generated SAS tokens |
Documentation
Links
Donations
If Vali-Blob is useful to you, consider supporting its development:
- Latin America — MercadoPago
- International — PayPal
License
Contributions
Issues and pull requests are welcome on GitHub.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 is compatible. 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 is compatible. |
| .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. |
-
.NETStandard 2.0
- Azure.Storage.Blobs (>= 12.22.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
.NETStandard 2.1
- Azure.Storage.Blobs (>= 12.22.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net6.0
- Azure.Storage.Blobs (>= 12.22.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net7.0
- Azure.Storage.Blobs (>= 12.22.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net8.0
- Azure.Storage.Blobs (>= 12.22.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net9.0
- Azure.Storage.Blobs (>= 12.22.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
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 |
|---|
See CHANGELOG.md at https://github.com/UBF21/Vali-Blob/blob/main/CHANGELOG.md