Microsoft.Extensions.Http.Polly 11.0.0-preview.4.26230.115

About

Microsoft.Extensions.Http.Polly integrates IHttpClientFactory with the Polly library to provide comprehensive resilience and transient fault-handling. It allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.

Note

This package is deprecated. Please use either Microsoft.Extensions.Resilience or Microsoft.Extensions.Http.Resilience instead.

How to Use

To use Microsoft.Extensions.Http.Polly, follow these steps:

Installation

dotnet add package Microsoft.Extensions.Http.Polly

Usage

Handle transient faults

AddTransientHttpErrorPolicy can be used define a policy that handles transient errors:

builder.Services.AddHttpClient("PollyWaitAndRetry")
    .AddTransientHttpErrorPolicy(policyBuilder =>
        policyBuilder.WaitAndRetryAsync(
            retryCount: 3,
            retryNumber => TimeSpan.FromMilliseconds(600)));

In the preceding example, failed requests are retried up to three times with a delay of 600 ms between attempts.

Dynamically select policies

To dynamically inspect a request and decide which policy apply, use the AddPolicyHandler extension method:

var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(
    TimeSpan.FromSeconds(10));
var longTimeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(
    TimeSpan.FromSeconds(30));

builder.Services.AddHttpClient("PollyDynamic")
    .AddPolicyHandler(httpRequestMessage =>
        httpRequestMessage.Method == HttpMethod.Get
            ? timeoutPolicy
            : longTimeoutPolicy);

In this example, if the outgoing request is an HTTP GET, a 10-second timeout is applied. For any other HTTP method, a 30-second timeout is used.

Main Types

The main types provided by this package are:

  • PollyHttpClientBuilderExtensions: Provides extension methods for configuring PolicyHttpMessageHandler message handlers as part of an HttpClient message handler pipeline
  • PolicyHttpMessageHandler: A DelegatingHandler implementation that executes request processing surrounded by a Polly.Policy
  • PollyServiceCollectionExtensions: Provides convenience extension methods to register Polly.Registry.IPolicyRegistry<string> and Polly.Registry.IReadOnlyPolicyRegistry<string> in a service collection
  • HttpRequestMessageExtensions: Provides extension methods for HttpRequestMessage Polly integration

Additional Documentation

For additional documentation and examples, refer to the official documentation on using Polly-based handlers in ASP.NET Core.

Feedback & Contributing

Microsoft.Extensions.Http.Polly is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.Extensions.Http.Polly.

Packages Downloads
Volo.Abp.Http.Client
Package Description
25
Volo.Abp.Http.Client
Package Description
24
Volo.Abp.Http.Client
Package Description
22
Volo.Abp.Http.Client
Package Description
21
Volo.Abp.Http.Client
Package Description
20
Volo.Abp.Http.Client
Package Description
19
Volo.Abp.Http.Client
Package Description
18

.NET Standard 2.0

Version Downloads Last updated
11.0.0-preview.4.26230.115 6 5/13/2026
11.0.0-preview.3.26207.106 8 5/3/2026
11.0.0-preview.2.26159.112 12 3/12/2026
11.0.0-preview.1.26104.118 12 2/11/2026
10.0.8 6 5/14/2026
10.0.7 7 5/3/2026
10.0.6 8 5/3/2026
10.0.5 11 3/17/2026
10.0.4 11 3/12/2026
10.0.3 13 2/11/2026
10.0.2 15 1/14/2026
10.0.1 23 12/12/2025
10.0.0 24 12/12/2025
10.0.0-rc.2.25502.107 24 12/12/2025
10.0.0-rc.1.25451.107 26 12/12/2025
10.0.0-preview.7.25380.108 21 12/12/2025
10.0.0-preview.6.25358.103 22 12/12/2025
10.0.0-preview.5.25277.114 17 12/12/2025
10.0.0-preview.4.25258.110 20 12/12/2025
10.0.0-preview.3.25172.1 18 12/12/2025
10.0.0-preview.2.25164.1 19 12/12/2025
10.0.0-preview.1.25120.3 21 12/12/2025
9.0.16 5 5/14/2026
9.0.15 9 5/3/2026
9.0.14 12 3/12/2026
9.0.13 13 2/11/2026
9.0.12 13 1/14/2026
9.0.11 19 12/12/2025
9.0.10 23 12/12/2025
9.0.9 24 12/12/2025
9.0.8 24 12/12/2025
9.0.7 19 12/12/2025
9.0.6 20 12/12/2025
9.0.5 24 12/12/2025
9.0.4 25 12/12/2025
9.0.3 23 12/12/2025
9.0.2 24 12/12/2025
9.0.1 25 12/12/2025
9.0.0 23 12/12/2025
9.0.0-rc.2.24474.3 26 12/12/2025
9.0.0-rc.1.24452.1 18 12/12/2025
9.0.0-preview.7.24406.2 18 12/12/2025
9.0.0-preview.6.24328.4 23 12/12/2025
9.0.0-preview.5.24306.11 19 12/11/2025
9.0.0-preview.4.24267.6 21 12/12/2025
9.0.0-preview.3.24172.13 19 12/12/2025
9.0.0-preview.2.24128.4 18 12/12/2025
9.0.0-preview.1.24081.5 19 12/12/2025
8.0.27 5 5/14/2026
8.0.26 8 5/3/2026
8.0.25 12 3/12/2026
8.0.24 13 2/11/2026
8.0.23 20 1/14/2026
8.0.22 23 12/12/2025
8.0.21 24 12/12/2025
8.0.20 20 12/12/2025
8.0.19 19 12/12/2025
8.0.18 24 12/12/2025
8.0.17 22 12/12/2025
8.0.16 22 12/12/2025
8.0.15 21 12/12/2025
8.0.14 22 12/12/2025
8.0.13 19 12/12/2025
8.0.12 21 12/12/2025
8.0.11 25 12/12/2025
8.0.10 22 12/12/2025
8.0.8 21 12/12/2025
8.0.7 25 12/12/2025
8.0.6 24 12/12/2025
8.0.5 21 12/12/2025
8.0.4 21 12/12/2025
8.0.3 24 12/12/2025
8.0.2 21 12/12/2025
8.0.1 22 12/12/2025
8.0.0 24 12/12/2025
8.0.0-rc.2.23480.2 19 12/12/2025
8.0.0-rc.1.23421.29 21 12/12/2025
8.0.0-preview.7.23375.9 16 12/12/2025
8.0.0-preview.6.23329.11 18 12/12/2025
8.0.0-preview.5.23302.2 20 12/12/2025
8.0.0-preview.4.23260.4 20 12/12/2025
8.0.0-preview.3.23177.8 18 12/12/2025
8.0.0-preview.2.23153.2 23 12/12/2025
8.0.0-preview.1.23112.2 23 12/12/2025
7.0.20 20 12/12/2025
7.0.19 23 12/12/2025
7.0.18 21 12/12/2025
7.0.17 23 12/12/2025
7.0.16 25 12/12/2025
7.0.15 21 12/12/2025
7.0.14 23 12/12/2025
7.0.13 24 12/12/2025
7.0.12 22 12/12/2025
7.0.11 23 12/12/2025
7.0.10 18 12/12/2025
7.0.9 16 12/12/2025
7.0.8 21 12/12/2025
7.0.7 19 12/12/2025
7.0.5 19 12/12/2025
7.0.4 22 12/12/2025
7.0.3 24 12/12/2025
7.0.2 29 12/12/2025
7.0.1 21 12/12/2025
7.0.0 22 12/12/2025
7.0.0-rc.2.22476.2 16 12/12/2025
7.0.0-rc.1.22427.2 26 12/12/2025
7.0.0-preview.7.22376.6 18 12/12/2025
7.0.0-preview.6.22330.3 21 12/12/2025
7.0.0-preview.5.22303.8 24 12/11/2025
7.0.0-preview.4.22251.1 20 12/12/2025
7.0.0-preview.3.22178.4 16 12/12/2025
7.0.0-preview.2.22153.2 19 12/12/2025
7.0.0-preview.1.22109.13 21 12/12/2025
6.0.36 20 12/12/2025
6.0.35 21 12/12/2025
6.0.33 22 12/12/2025
6.0.32 23 12/12/2025
6.0.31 23 12/12/2025
6.0.30 20 12/12/2025
6.0.29 21 12/12/2025
6.0.28 19 12/12/2025
6.0.27 19 12/12/2025
6.0.26 24 12/12/2025
6.0.25 21 12/12/2025
6.0.24 17 12/12/2025
6.0.23 21 12/12/2025
6.0.22 20 12/12/2025
6.0.21 20 12/12/2025
6.0.20 23 12/12/2025
6.0.19 17 12/12/2025
6.0.18 22 12/12/2025
6.0.16 23 12/12/2025
6.0.15 22 12/12/2025
6.0.14 23 12/12/2025
6.0.13 20 12/12/2025
6.0.12 19 12/12/2025
6.0.11 19 12/12/2025
6.0.10 27 12/12/2025
6.0.9 21 12/12/2025
6.0.8 23 12/12/2025
6.0.7 20 12/12/2025
6.0.6 21 12/12/2025
6.0.5 19 12/12/2025
6.0.4 18 12/12/2025
6.0.3 22 12/12/2025
6.0.2 24 12/12/2025
6.0.1 21 12/12/2025
6.0.0 19 12/12/2025
6.0.0-rc.2.21480.10 21 12/12/2025
6.0.0-rc.1.21452.15 18 12/12/2025
6.0.0-preview.7.21378.6 22 12/12/2025
6.0.0-preview.6.21355.2 19 12/12/2025
6.0.0-preview.5.21301.17 22 12/12/2025
6.0.0-preview.4.21253.5 21 12/12/2025
6.0.0-preview.3.21201.13 19 12/12/2025
6.0.0-preview.2.21154.6 20 12/12/2025
6.0.0-preview.1.21103.6 19 12/12/2025
5.0.1 21 12/12/2025
5.0.0 25 12/12/2025
5.0.0-rc.2.20478.4 21 12/12/2025
5.0.0-rc.1.20451.7 20 12/12/2025
5.0.0-preview.8.20407.3 20 12/12/2025
5.0.0-preview.7.20365.4 20 12/12/2025
5.0.0-preview.6.20306.1 22 12/12/2025
5.0.0-preview.5.20278.3 24 12/12/2025
5.0.0-preview.4.20251.2 17 12/12/2025
5.0.0-preview.3.20215.2 22 12/12/2025
5.0.0-preview.2.20160.3 21 12/12/2025
5.0.0-preview.1.20120.4 21 12/12/2025
3.1.32 22 12/12/2025
3.1.31 19 12/12/2025
3.1.30 20 12/12/2025
3.1.29 23 12/11/2025
3.1.28 24 12/12/2025
3.1.27 23 12/12/2025
3.1.26 21 12/12/2025
3.1.25 20 12/12/2025
3.1.24 25 12/12/2025
3.1.23 20 12/12/2025
3.1.22 20 12/12/2025
3.1.21 23 12/12/2025
3.1.20 22 12/12/2025
3.1.19 21 12/12/2025
3.1.18 20 12/12/2025
3.1.17 18 12/12/2025
3.1.16 23 12/12/2025
3.1.15 21 12/12/2025
3.1.14 22 12/12/2025
3.1.13 23 12/12/2025
3.1.12 22 12/12/2025
3.1.11 23 12/12/2025
3.1.10 22 12/12/2025
3.1.9 23 12/12/2025
3.1.8 22 12/12/2025
3.1.7 24 12/12/2025
3.1.6 24 12/12/2025
3.1.5 23 12/12/2025
3.1.4 23 12/12/2025
3.1.3 22 12/12/2025
3.1.2 19 12/12/2025
3.1.1 23 12/12/2025
3.1.0 21 12/12/2025
3.1.0-preview3.19553.2 18 12/12/2025
3.1.0-preview2.19525.4 22 12/12/2025
3.1.0-preview1.19506.1 21 12/12/2025
3.0.3 21 12/12/2025
3.0.2 21 12/12/2025
3.0.1 21 12/12/2025
3.0.0 22 12/12/2025
3.0.0-rc1.19456.10 17 12/12/2025
3.0.0-preview9.19423.4 19 12/12/2025
3.0.0-preview8.19405.4 18 12/12/2025
3.0.0-preview7.19362.4 18 12/12/2025
3.0.0-preview6.19304.6 19 12/12/2025
3.0.0-preview5.19227.9 20 12/12/2025
3.0.0-preview4.19216.2 19 12/12/2025
3.0.0-preview3.19153.1 20 12/12/2025
3.0.0-preview.19074.2 21 12/12/2025
3.0.0-preview.18572.1 18 12/12/2025
2.2.0 24 12/12/2025
2.2.0-preview3-35497 18 12/11/2025
2.2.0-preview2-35157 19 12/12/2025
2.2.0-preview1-35029 20 12/12/2025
2.1.1 20 12/12/2025
2.1.0 20 12/12/2025
2.1.0-rc1-final 20 12/12/2025
2.1.0-preview2-final 19 12/11/2025