Polly v8 resilience pipelines for Azure Queue Storage — retry, timeout, and circuit-breaker for QueueClient operations.
Azure Queue Storage is a durable, scalable message queue — but transient failures (throttling 429, service unavailability 503, gateway timeouts 504) can disrupt your messaging pipeline. PollyAzureQueueStorage wraps QueueClient in a Polly v8 ResiliencePipeline so send, receive, peek, and delete all automatically retry on transient errors.
Completes the Azure storage trio alongside PollyAzureBlob and PollyAzureTableStorage.
dotnet add package PollyAzureQueueStorage
`csharp services.AddPollyAzureQueueStorage( connectionString: Environment.GetEnvironmentVariable("AZURE_STORAGE_CONN"), queueName: "my-queue", configure: pipeline => pipeline .AddRetry(new RetryStrategyOptions { MaxRetryAttempts = 3, Delay = TimeSpan.FromSeconds(1), BackoffType = DelayBackoffType.Exponential, ShouldHandle = QueueStorageTransientErrors.IsTransient, }) .AddTimeout(TimeSpan.FromSeconds(30)));
// Use via DI public class QueueService(ResilientQueueClient queue) { public async Task SendAsync(string message, CancellationToken ct = default) => await queue.SendMessageAsync(message, ct); } `
`csharp var queueClient = new QueueClient(connectionString, "my-queue");
var resilient = queueClient.WithPolly(pipeline => pipeline.AddRetry(new RetryStrategyOptions { MaxRetryAttempts = 3, Delay = TimeSpan.FromSeconds(1), BackoffType = DelayBackoffType.Exponential, ShouldHandle = QueueStorageTransientErrors.IsTransient, }));
await resilient.SendMessageAsync("hello"); var messages = await resilient.ReceiveMessagesAsync(maxMessages: 10); `
| Method | Description |
|---|---|
| SendMessageAsync(string, CancellationToken) | Enqueue a plain-text message |
| SendMessageAsync(BinaryData, CancellationToken) | Enqueue binary/JSON message |
| ReceiveMessagesAsync(int, TimeSpan?, CancellationToken) | Dequeue up to N messages |
| PeekMessagesAsync(int, CancellationToken) | Peek without dequeuing |
| DeleteMessageAsync(string, string, CancellationToken) | Delete after processing |
| ExecuteAsync(Func<CancellationToken, ValueTask>, CancellationToken) | Custom operation |
QueueStorageTransientErrors.IsTransient handles:
| Exception | Condition |
|---|---|
| RequestFailedException | Status 429 (throttled), 503 (unavailable), 504 (gateway timeout) |
| HttpRequestException | Network-level failure |
| TaskCanceledException | Timeout or cancellation |
et6.0 · et8.0 · et9.0
| Package | Wraps |
|---|---|
| PollyEFCore | Entity Framework Core DbContext |
| PollyDapper | Dapper IDbConnection |
| PollyMongo | MongoDB IMongoCollection |
| PollyAzureBlob | Azure Blob Storage BlobContainerClient |
| PollyNpgsql | Npgsql PostgreSQL NpgsqlConnection |
| PollySqlClient | System.Data.SqlClient SqlConnection |
| PollyCosmosDb | Azure Cosmos DB CosmosClient |
| PollyGrpc | gRPC channel calls |
| PollyRabbitMQ | RabbitMQ IModel channel |
| PollyAzureServiceBus | Azure Service Bus sender/receiver |
| PollyRedis | StackExchange.Redis IDatabase |
| PollyMediatR | MediatR IMediator |
| PollyOpenAI | OpenAI ChatClient |
| PollyHealthChecks | ASP.NET Core health checks |
| PollyBackoff | Pre-built backoff pipelines |
| PollyChaos | Chaos engineering helpers |
| PollyKafka | Confluent Kafka producer/consumer |
| PollySignalR | SignalR HubConnection |
| PollyRateLimiter | .NET rate limiting middleware |
| PollyElasticsearch | Elastic.Clients.Elasticsearch |
| PollyAzureKeyVault | Azure Key Vault SecretClient |
| PollyAzureEventHub | Azure Event Hubs producer |
| PollySendGrid | SendGrid email client |
| PollyMassTransit | MassTransit IBus |
| PollyAzureTableStorage | Azure Table Storage TableClient |
| PollyMailKit | MailKit SMTP email client |
| PollyHangfire | Hangfire IBackgroundJobClient |
The author of this package is available for consulting on Polly v8 resilience, Azure cloud architecture, and clean .NET design.
→ solidqualitysolutions.com · LinkedIn
MIT © Justin Bannister