PollyAzureBlob 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package PollyAzureBlob --version 1.0.0
                    
NuGet\Install-Package PollyAzureBlob -Version 1.0.0
                    
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="PollyAzureBlob" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PollyAzureBlob" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PollyAzureBlob" />
                    
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 PollyAzureBlob --version 1.0.0
                    
#r "nuget: PollyAzureBlob, 1.0.0"
                    
#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 PollyAzureBlob@1.0.0
                    
#: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=PollyAzureBlob&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PollyAzureBlob&version=1.0.0
                    
Install as a Cake Tool

PollyAzureBlob

NuGet NuGet Downloads CI

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>)

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

Package Downloads Description
PollyAzureServiceBus Downloads Polly v8 resilience for Azure Service Bus senders and receivers
PollyEFCore Downloads Polly v8 resilience for EF Core queries and SaveChanges
PollyDapper Downloads Polly v8 resilience for Dapper queries and commands
PollyMongo Downloads Polly v8 resilience for MongoDB.Driver
PollyRedis Downloads Polly v8 resilience for StackExchange.Redis
PollyOpenAI Downloads Polly v8 resilience for OpenAI and Azure OpenAI
PollyMediatR Downloads Polly v8 resilience pipelines for MediatR
PollyHealthChecks Downloads ASP.NET Core health checks for Polly v8 circuit breakers
PollyBackoff Downloads Jitter, linear & custom backoff for Polly v8 retry
PollyChaos Downloads Fault & latency injection (Simmy for Polly v8)

License

MIT

Product 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. 
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
1.0.2 244 8/7/2026
1.0.1 144 7/7/2026
1.0.0 133 6/24/2026

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.