PollyAzureBlob 1.0.0
See the version list below for details.
dotnet add package PollyAzureBlob --version 1.0.0
NuGet\Install-Package PollyAzureBlob -Version 1.0.0
<PackageReference Include="PollyAzureBlob" Version="1.0.0" />
<PackageVersion Include="PollyAzureBlob" Version="1.0.0" />
<PackageReference Include="PollyAzureBlob" />
paket add PollyAzureBlob --version 1.0.0
#r "nuget: PollyAzureBlob, 1.0.0"
#:package PollyAzureBlob@1.0.0
#addin nuget:?package=PollyAzureBlob&version=1.0.0
#tool nuget:?package=PollyAzureBlob&version=1.0.0
PollyAzureBlob
Polly v8 resilience for Azure Blob Storage — retry, timeout, and circuit-breaker for BlobClient and BlobContainerClient with a single WithPolly(pipeline) call. Drop-in decorator, zero changes to your existing blob code.
// Before
await blobClient.UploadAsync(stream, overwrite: true);
// After — automatic retry + timeout on every operation
var resilient = blobClient.WithPolly(pipeline);
await resilient.UploadAsync(stream, overwrite: true);
Installation
dotnet add package PollyAzureBlob
Targets net6.0, net8.0, and net9.0.
Dependencies: Polly.Core 8.*, Azure.Storage.Blobs 12.*, Microsoft.Extensions.DependencyInjection.Abstractions 8.*
Quick start
BlobClient
using PollyAzureBlob;
var pipeline = new ResiliencePipelineBuilder()
.AddRetry(new RetryStrategyOptions
{
MaxRetryAttempts = 3,
Delay = TimeSpan.FromMilliseconds(500),
BackoffType = DelayBackoffType.Exponential,
ShouldHandle = new PredicateBuilder().Handle<RequestFailedException>(ex =>
ex.Status is 408 or 429 or 500 or 502 or 503 or 504),
})
.AddTimeout(TimeSpan.FromSeconds(30))
.Build();
var resilient = blobClient.WithPolly(pipeline);
// Upload
await resilient.UploadAsync(stream, overwrite: true);
// Download
var result = await resilient.DownloadContentAsync();
var data = result.Value.Content;
// Delete
await resilient.DeleteIfExistsAsync();
// Check existence
var exists = await resilient.ExistsAsync();
BlobContainerClient
var resilientContainer = containerClient.WithPolly(pipeline);
// Create container
await resilientContainer.CreateIfNotExistsAsync();
// Upload blob via container
await resilientContainer.UploadBlobAsync("report.pdf", stream);
// List blobs
var blobs = await resilientContainer.GetBlobsAsync(prefix: "reports/");
// Get a resilient BlobClient — shares the same pipeline
var resilientBlob = resilientContainer.GetBlobClient("report.pdf");
var content = await resilientBlob.DownloadContentAsync();
Dependency injection
// Program.cs
builder.Services.AddSingleton(_ =>
new BlobServiceClient(builder.Configuration["AzureStorage:ConnectionString"]));
builder.Services.AddPollyAzureBlob(pipeline =>
pipeline
.AddRetry(new RetryStrategyOptions
{
MaxRetryAttempts = 3,
Delay = TimeSpan.FromMilliseconds(500),
BackoffType = DelayBackoffType.Exponential,
ShouldHandle = new PredicateBuilder().Handle<RequestFailedException>(ex =>
ex.Status is 408 or 429 or 500 or 502 or 503 or 504),
})
.AddTimeout(TimeSpan.FromSeconds(30))
.AddCircuitBreaker(new CircuitBreakerStrategyOptions
{
FailureRatio = 0.5,
MinimumThroughput = 5,
SamplingDuration = TimeSpan.FromSeconds(30),
BreakDuration = TimeSpan.FromSeconds(15),
}));
// Repository
public class BlobRepository(BlobContainerClient container, ResiliencePipeline pipeline)
{
public Task UploadAsync(string name, Stream content) =>
container.WithPolly(pipeline).UploadBlobAsync(name, content);
public async Task<BinaryData> DownloadAsync(string name) =>
(await container.WithPolly(pipeline).GetBlobClient(name).DownloadContentAsync()).Value.Content;
}
Supported operations
ResilientBlobClient
| Method | Description |
|---|---|
UploadAsync(Stream, ...) |
Upload from stream |
UploadAsync(BinaryData, ...) |
Upload from BinaryData |
DownloadContentAsync |
Download blob content |
DownloadToAsync |
Download to stream |
DeleteAsync |
Delete blob |
DeleteIfExistsAsync |
Delete blob if it exists |
ExistsAsync |
Check if blob exists |
GetPropertiesAsync |
Get blob properties |
SetHttpHeadersAsync |
Set HTTP headers |
SetMetadataAsync |
Set metadata |
CreateSnapshotAsync |
Create blob snapshot |
ResilientBlobContainerClient
| Method | Description |
|---|---|
GetBlobClient(name) |
Get a ResilientBlobClient sharing the same pipeline |
CreateAsync |
Create container |
CreateIfNotExistsAsync |
Create container if not exists |
DeleteAsync |
Delete container |
DeleteIfExistsAsync |
Delete container if exists |
ExistsAsync |
Check if container exists |
GetPropertiesAsync |
Get container properties |
UploadBlobAsync |
Upload blob by name |
DeleteBlobAsync |
Delete blob by name |
DeleteBlobIfExistsAsync |
Delete blob by name if exists |
GetBlobsAsync |
List blobs (returns List<BlobItem>) |
Recommended transient exceptions
Azure Blob Storage throws RequestFailedException. These HTTP status codes are safe to retry:
ShouldHandle = new PredicateBuilder().Handle<RequestFailedException>(ex =>
ex.Status is 408 // Request Timeout
or 429 // Too Many Requests (throttled)
or 500 // Internal Server Error
or 502 // Bad Gateway
or 503 // Service Unavailable
or 504) // Gateway Timeout
Pipeline order
[Timeout] → [Retry] → [Circuit Breaker] → [Azure Blob Storage]
pipeline
.AddTimeout(TimeSpan.FromSeconds(30)) // 1. Overall deadline
.AddRetry(retryOptions) // 2. Retry transient failures
.AddCircuitBreaker(cbOptions) // 3. Open circuit under sustained failures
Related packages
| Package | Downloads | Description |
|---|---|---|
| PollyAzureServiceBus | Polly v8 resilience for Azure Service Bus senders and receivers | |
| PollyEFCore | Polly v8 resilience for EF Core queries and SaveChanges | |
| PollyDapper | Polly v8 resilience for Dapper queries and commands | |
| PollyMongo | Polly v8 resilience for MongoDB.Driver | |
| PollyRedis | Polly v8 resilience for StackExchange.Redis | |
| PollyOpenAI | Polly v8 resilience for OpenAI and Azure OpenAI | |
| PollyMediatR | Polly v8 resilience pipelines for MediatR | |
| PollyHealthChecks | ASP.NET Core health checks for Polly v8 circuit breakers | |
| PollyBackoff | Jitter, linear & custom backoff for Polly v8 retry | |
| PollyChaos | Fault & latency injection (Simmy for Polly v8) |
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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 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. |
-
net6.0
- Azure.Storage.Blobs (>= 12.29.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Polly.Core (>= 8.7.0)
-
net8.0
- Azure.Storage.Blobs (>= 12.29.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Polly.Core (>= 8.7.0)
-
net9.0
- Azure.Storage.Blobs (>= 12.29.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Polly.Core (>= 8.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.0: Initial release. ResilientBlobClient and ResilientBlobContainerClient wrap Azure Blob Storage operations in a Polly v8 ResiliencePipeline. Supports net6.0, net8.0, and net9.0.