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

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
Microsoft.Extensions.Http.Resilience
Resilience mechanisms for HTTP Client.
110
Microsoft.Extensions.Http.Resilience
Resilience mechanisms for HTTP Client.
114
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
107
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
109
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
114
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
119
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
107
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
110
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
112
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
113
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
117
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
118
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
121
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
129

.NET Standard 2.0

Version Downloads Last updated
11.0.0-preview.3.26207.106 4 04/14/2026
11.0.0-preview.2.26159.112 12 03/12/2026
11.0.0-preview.1.26104.118 17 02/13/2026
10.0.7 3 04/21/2026
10.0.6 3 04/14/2026
10.0.5 10 03/12/2026
10.0.4 11 03/12/2026
10.0.3 20 02/13/2026
10.0.2 20 01/13/2026
10.0.1 52 12/12/2025
10.0.0 65 11/12/2025
10.0.0-rc.2.25502.107 66 10/14/2025
10.0.0-rc.1.25451.107 56 09/09/2025
10.0.0-preview.7.25380.108 76 08/13/2025
10.0.0-preview.6.25358.103 79 07/15/2025
10.0.0-preview.5.25277.114 79 06/06/2025
10.0.0-preview.4.25258.110 106 05/15/2025
10.0.0-preview.3.25172.1 100 04/12/2025
10.0.0-preview.2.25164.1 92 03/31/2025
10.0.0-preview.1.25120.3 90 04/01/2025
9.0.15 5 04/14/2026
9.0.14 12 03/12/2026
9.0.13 15 02/13/2026
9.0.12 20 01/13/2026
9.0.11 58 11/12/2025
9.0.10 56 10/14/2025
9.0.9 77 09/09/2025
9.0.8 82 08/05/2025
9.0.7 88 07/09/2025
9.0.6 79 06/12/2025
9.0.5 104 05/16/2025
9.0.4 103 04/11/2025
9.0.3 107 04/01/2025
9.0.2 106 04/01/2025
9.0.1 105 04/01/2025
9.0.0 107 04/01/2025
9.0.0-rc.2.24474.3 97 04/01/2025
9.0.0-rc.1.24452.1 85 04/01/2025
9.0.0-preview.7.24406.2 97 04/01/2025
9.0.0-preview.6.24328.4 93 04/01/2025
9.0.0-preview.5.24306.11 92 04/01/2025
9.0.0-preview.4.24267.6 111 04/01/2025
9.0.0-preview.3.24172.13 93 04/01/2025
9.0.0-preview.2.24128.4 94 04/01/2025
9.0.0-preview.1.24081.5 114 04/01/2025
8.0.26 4 04/14/2026
8.0.25 14 03/12/2026
8.0.24 11 02/13/2026
8.0.23 20 01/13/2026
8.0.22 50 11/12/2025
8.0.21 59 10/14/2025
8.0.20 77 09/09/2025
8.0.19 73 08/05/2025
8.0.18 89 07/09/2025
8.0.17 71 06/12/2025
8.0.16 80 05/16/2025
8.0.15 92 04/10/2025
8.0.14 103 04/01/2025
8.0.13 101 04/01/2025
8.0.12 101 04/01/2025
8.0.11 89 04/01/2025
8.0.10 106 04/01/2025
8.0.8 108 04/01/2025
8.0.7 98 04/01/2025
8.0.6 98 04/01/2025
8.0.5 113 04/01/2025
8.0.4 104 04/07/2025
8.0.3 101 04/03/2025
8.0.2 97 04/01/2025
8.0.1 114 04/01/2025
8.0.0 90 04/01/2025
8.0.0-rc.2.23480.2 89 04/01/2025
8.0.0-rc.1.23421.29 102 04/01/2025
8.0.0-preview.7.23375.9 94 04/01/2025
8.0.0-preview.6.23329.11 100 04/01/2025
8.0.0-preview.5.23302.2 108 04/01/2025
8.0.0-preview.4.23260.4 98 04/01/2025
8.0.0-preview.3.23177.8 111 04/01/2025
8.0.0-preview.2.23153.2 92 04/01/2025
8.0.0-preview.1.23112.2 93 04/01/2025
7.0.20 102 04/01/2025
7.0.19 99 04/01/2025
7.0.18 100 04/01/2025
7.0.17 90 04/01/2025
7.0.16 93 04/01/2025
7.0.15 114 04/01/2025
7.0.14 113 04/01/2025
7.0.13 107 04/01/2025
7.0.12 101 04/01/2025
7.0.11 93 04/01/2025
7.0.10 85 04/01/2025
7.0.9 107 04/01/2025
7.0.8 110 04/01/2025
7.0.7 108 04/01/2025
7.0.5 100 04/01/2025
7.0.4 116 04/01/2025
7.0.3 87 04/01/2025
7.0.2 102 04/01/2025
7.0.1 114 04/01/2025
7.0.0 88 04/01/2025
7.0.0-rc.2.22476.2 105 04/01/2025
7.0.0-rc.1.22427.2 105 04/01/2025
7.0.0-preview.7.22376.6 110 04/01/2025
7.0.0-preview.6.22330.3 91 04/01/2025
7.0.0-preview.5.22303.8 89 04/01/2025
7.0.0-preview.4.22251.1 88 04/01/2025
7.0.0-preview.3.22178.4 96 04/01/2025
7.0.0-preview.2.22153.2 81 04/01/2025
7.0.0-preview.1.22109.13 118 04/01/2025
6.0.36 94 04/01/2025
6.0.35 107 04/01/2025
6.0.33 98 04/01/2025
6.0.32 114 04/01/2025
6.0.31 122 04/01/2025
6.0.30 102 04/01/2025
6.0.29 107 04/01/2025
6.0.28 101 04/01/2025
6.0.27 96 04/01/2025
6.0.26 97 04/01/2025
6.0.25 108 04/01/2025
6.0.24 87 04/01/2025
6.0.23 95 04/01/2025
6.0.22 99 04/01/2025
6.0.21 107 04/01/2025
6.0.20 84 04/01/2025
6.0.19 108 04/01/2025
6.0.18 92 04/01/2025
6.0.16 90 04/01/2025
6.0.15 95 04/01/2025
6.0.14 95 04/01/2025
6.0.13 101 04/01/2025
6.0.12 95 04/01/2025
6.0.11 90 04/01/2025
6.0.10 109 04/01/2025
6.0.9 84 04/06/2025
6.0.8 95 04/01/2025
6.0.7 99 04/01/2025
6.0.6 99 04/01/2025
6.0.5 123 04/01/2025
6.0.4 85 04/01/2025
6.0.3 101 04/01/2025
6.0.2 101 04/01/2025
6.0.1 127 04/01/2025
6.0.0 89 04/01/2025
6.0.0-rc.2.21480.10 96 04/01/2025
6.0.0-rc.1.21452.15 127 04/01/2025
6.0.0-preview.7.21378.6 115 04/01/2025
6.0.0-preview.6.21355.2 90 04/01/2025
6.0.0-preview.5.21301.17 88 04/01/2025
6.0.0-preview.4.21253.5 103 04/01/2025
6.0.0-preview.3.21201.13 86 04/01/2025
6.0.0-preview.2.21154.6 104 04/01/2025
6.0.0-preview.1.21103.6 102 04/07/2025
5.0.1 102 04/01/2025
5.0.0 117 04/01/2025
5.0.0-rc.2.20478.4 95 04/01/2025
5.0.0-rc.1.20451.7 92 04/01/2025
5.0.0-preview.8.20407.3 87 04/01/2025
5.0.0-preview.7.20365.4 89 04/01/2025
5.0.0-preview.6.20306.1 99 04/01/2025
5.0.0-preview.5.20278.3 89 04/01/2025
5.0.0-preview.4.20251.2 100 04/01/2025
5.0.0-preview.3.20215.2 97 04/01/2025
5.0.0-preview.2.20160.3 97 04/01/2025
5.0.0-preview.1.20120.4 84 04/01/2025
3.1.32 96 04/01/2025
3.1.31 95 04/01/2025
3.1.30 89 04/01/2025
3.1.29 101 04/01/2025
3.1.28 95 04/01/2025
3.1.27 102 04/01/2025
3.1.26 93 04/01/2025
3.1.25 97 04/01/2025
3.1.24 91 04/01/2025
3.1.23 109 04/01/2025
3.1.22 92 04/01/2025
3.1.21 105 04/01/2025
3.1.20 90 04/01/2025
3.1.19 80 04/01/2025
3.1.18 94 04/01/2025
3.1.17 92 04/01/2025
3.1.16 96 04/01/2025
3.1.15 89 04/01/2025
3.1.14 99 04/01/2025
3.1.13 102 04/01/2025
3.1.12 86 04/01/2025
3.1.11 102 04/01/2025
3.1.10 110 04/01/2025
3.1.9 97 04/01/2025
3.1.8 114 04/01/2025
3.1.7 102 04/01/2025
3.1.6 109 04/01/2025
3.1.5 106 04/01/2025
3.1.4 116 04/01/2025
3.1.3 91 04/01/2025
3.1.2 95 04/01/2025
3.1.1 73 04/01/2025
3.1.0 111 04/01/2025
3.1.0-preview3.19553.2 112 03/31/2025
3.1.0-preview2.19525.4 104 04/01/2025
3.1.0-preview1.19506.1 79 04/01/2025
3.0.3 101 04/01/2025
3.0.2 110 04/01/2025
3.0.1 94 04/01/2025
3.0.0 97 04/01/2025
3.0.0-rc1.19456.10 84 04/01/2025
3.0.0-preview9.19423.4 94 04/01/2025
3.0.0-preview8.19405.4 85 04/01/2025
3.0.0-preview7.19362.4 97 04/01/2025
3.0.0-preview6.19304.6 97 04/01/2025
3.0.0-preview5.19227.9 92 04/01/2025
3.0.0-preview4.19216.2 96 04/01/2025
3.0.0-preview3.19153.1 98 04/01/2025
3.0.0-preview.19074.2 100 04/01/2025
3.0.0-preview.18572.1 89 03/31/2025
2.2.0 112 04/01/2025
2.2.0-preview3-35497 100 04/01/2025
2.2.0-preview2-35157 93 04/01/2025
2.2.0-preview1-35029 95 04/01/2025
2.1.1 103 04/01/2025
2.1.0 101 04/01/2025
2.1.0-rc1-final 104 03/31/2025
2.1.0-preview2-final 94 03/31/2025