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
Microsoft.Extensions.Http.Resilience
Resilience mechanisms for HTTP Client.
120
Microsoft.Extensions.Http.Resilience
Resilience mechanisms for HTTP Client.
122
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
117
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
119
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
122
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
123
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
124
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
126
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.
119
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.
122
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
123
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
124
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
126
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
129
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
132
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
138

.NET Standard 2.0

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