Microsoft.Extensions.Http.Polly 10.0.12

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.
140
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
140
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
142
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
144
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
146
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
148
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
149
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
142
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
144
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
146
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
147
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
149
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
150
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
156
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
158
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
163

.NET Standard 2.0

Version Downloads Last updated
11.0.0-rc.1.26425.128 5 09/09/2026
11.0.0-preview.7.26381.103 10 08/12/2026
11.0.0-preview.6.26359.118 19 07/15/2026
11.0.0-preview.5.26302.115 22 06/10/2026
11.0.0-preview.4.26230.115 34 05/13/2026
11.0.0-preview.3.26207.106 44 04/14/2026
11.0.0-preview.2.26159.112 45 03/12/2026
11.0.0-preview.1.26104.118 44 02/13/2026
10.0.12 3 09/10/2026
10.0.11 10 08/12/2026
10.0.10 18 07/15/2026
10.0.9 22 06/10/2026
10.0.8 27 05/13/2026
10.0.7 36 04/21/2026
10.0.6 37 04/14/2026
10.0.5 44 03/12/2026
10.0.4 38 03/12/2026
10.0.3 54 02/13/2026
10.0.2 51 01/13/2026
10.0.1 68 12/12/2025
10.0.0 97 11/12/2025
10.0.0-rc.2.25502.107 90 10/14/2025
10.0.0-rc.1.25451.107 75 09/09/2025
10.0.0-preview.7.25380.108 103 08/13/2025
10.0.0-preview.6.25358.103 102 07/15/2025
10.0.0-preview.5.25277.114 97 06/06/2025
10.0.0-preview.4.25258.110 135 05/15/2025
10.0.0-preview.3.25172.1 124 04/12/2025
10.0.0-preview.2.25164.1 120 03/31/2025
10.0.0-preview.1.25120.3 116 04/01/2025
9.0.20 3 09/09/2026
9.0.19 10 08/12/2026
9.0.18 18 07/15/2026
9.0.17 22 06/10/2026
9.0.16 23 05/13/2026
9.0.15 38 04/14/2026
9.0.14 38 03/12/2026
9.0.13 43 02/13/2026
9.0.12 45 01/13/2026
9.0.11 89 11/12/2025
9.0.10 82 10/14/2025
9.0.9 103 09/09/2025
9.0.8 113 08/05/2025
9.0.7 116 07/09/2025
9.0.6 103 06/12/2025
9.0.5 134 05/16/2025
9.0.4 129 04/11/2025
9.0.3 136 04/01/2025
9.0.2 136 04/01/2025
9.0.1 134 04/01/2025
9.0.0 136 04/01/2025
9.0.0-rc.2.24474.3 124 04/01/2025
9.0.0-rc.1.24452.1 100 04/01/2025
9.0.0-preview.7.24406.2 122 04/01/2025
9.0.0-preview.6.24328.4 120 04/01/2025
9.0.0-preview.5.24306.11 120 04/01/2025
9.0.0-preview.4.24267.6 127 04/01/2025
9.0.0-preview.3.24172.13 118 04/01/2025
9.0.0-preview.2.24128.4 120 04/01/2025
9.0.0-preview.1.24081.5 133 04/01/2025
8.0.31 5 09/09/2026
8.0.30 11 08/12/2026
8.0.29 15 07/15/2026
8.0.28 22 06/10/2026
8.0.27 21 05/12/2026
8.0.26 34 04/14/2026
8.0.25 37 03/12/2026
8.0.24 41 02/13/2026
8.0.23 50 01/13/2026
8.0.22 78 11/12/2025
8.0.21 88 10/14/2025
8.0.20 93 09/09/2025
8.0.19 100 08/05/2025
8.0.18 105 07/09/2025
8.0.17 88 06/12/2025
8.0.16 100 05/16/2025
8.0.15 122 04/10/2025
8.0.14 126 04/01/2025
8.0.13 128 04/01/2025
8.0.12 129 04/01/2025
8.0.11 121 04/01/2025
8.0.10 136 04/01/2025
8.0.8 126 04/01/2025
8.0.7 115 04/01/2025
8.0.6 117 04/01/2025
8.0.5 136 04/01/2025
8.0.4 123 04/07/2025
8.0.3 120 04/03/2025
8.0.2 113 04/01/2025
8.0.1 148 04/01/2025
8.0.0 115 04/01/2025
8.0.0-rc.2.23480.2 116 04/01/2025
8.0.0-rc.1.23421.29 126 04/01/2025
8.0.0-preview.7.23375.9 118 04/01/2025
8.0.0-preview.6.23329.11 132 04/01/2025
8.0.0-preview.5.23302.2 126 04/01/2025
8.0.0-preview.4.23260.4 125 04/01/2025
8.0.0-preview.3.23177.8 136 04/01/2025
8.0.0-preview.2.23153.2 117 04/01/2025
8.0.0-preview.1.23112.2 113 04/01/2025
7.0.20 131 04/01/2025
7.0.19 127 04/01/2025
7.0.18 131 04/01/2025
7.0.17 118 04/01/2025
7.0.16 116 04/01/2025
7.0.15 151 04/01/2025
7.0.14 137 04/01/2025
7.0.13 128 04/01/2025
7.0.12 125 04/01/2025
7.0.11 120 04/01/2025
7.0.10 111 04/01/2025
7.0.9 137 04/01/2025
7.0.8 141 04/01/2025
7.0.7 138 04/01/2025
7.0.5 126 04/01/2025
7.0.4 138 04/01/2025
7.0.3 114 04/01/2025
7.0.2 130 04/01/2025
7.0.1 134 04/01/2025
7.0.0 116 04/01/2025
7.0.0-rc.2.22476.2 128 04/01/2025
7.0.0-rc.1.22427.2 118 04/01/2025
7.0.0-preview.7.22376.6 130 04/01/2025
7.0.0-preview.6.22330.3 117 04/01/2025
7.0.0-preview.5.22303.8 106 04/01/2025
7.0.0-preview.4.22251.1 109 04/01/2025
7.0.0-preview.3.22178.4 122 04/01/2025
7.0.0-preview.2.22153.2 107 04/01/2025
7.0.0-preview.1.22109.13 132 04/01/2025
6.0.36 122 04/01/2025
6.0.35 130 04/01/2025
6.0.33 126 04/01/2025
6.0.32 147 04/01/2025
6.0.31 154 04/01/2025
6.0.30 126 04/01/2025
6.0.29 123 04/01/2025
6.0.28 130 04/01/2025
6.0.27 118 04/01/2025
6.0.26 121 04/01/2025
6.0.25 139 04/01/2025
6.0.24 108 04/01/2025
6.0.23 121 04/01/2025
6.0.22 127 04/01/2025
6.0.21 131 04/01/2025
6.0.20 112 04/01/2025
6.0.19 136 04/01/2025
6.0.18 116 04/01/2025
6.0.16 121 04/01/2025
6.0.15 122 04/01/2025
6.0.14 119 04/01/2025
6.0.13 136 04/01/2025
6.0.12 119 04/01/2025
6.0.11 117 04/01/2025
6.0.10 133 04/01/2025
6.0.9 108 04/06/2025
6.0.8 122 04/01/2025
6.0.7 129 04/01/2025
6.0.6 127 04/01/2025
6.0.5 152 04/01/2025
6.0.4 113 04/01/2025
6.0.3 136 04/01/2025
6.0.2 131 04/01/2025
6.0.1 157 04/01/2025
6.0.0 120 04/01/2025
6.0.0-rc.2.21480.10 124 04/01/2025
6.0.0-rc.1.21452.15 144 04/01/2025
6.0.0-preview.7.21378.6 138 04/01/2025
6.0.0-preview.6.21355.2 126 04/01/2025
6.0.0-preview.5.21301.17 116 04/01/2025
6.0.0-preview.4.21253.5 133 04/01/2025
6.0.0-preview.3.21201.13 112 04/01/2025
6.0.0-preview.2.21154.6 134 04/01/2025
6.0.0-preview.1.21103.6 121 04/07/2025
5.0.1 130 04/01/2025
5.0.0 145 04/01/2025
5.0.0-rc.2.20478.4 118 04/01/2025
5.0.0-rc.1.20451.7 115 04/01/2025
5.0.0-preview.8.20407.3 114 04/01/2025
5.0.0-preview.7.20365.4 111 04/01/2025
5.0.0-preview.6.20306.1 126 04/01/2025
5.0.0-preview.5.20278.3 117 04/01/2025
5.0.0-preview.4.20251.2 124 04/01/2025
5.0.0-preview.3.20215.2 128 04/01/2025
5.0.0-preview.2.20160.3 123 04/01/2025
5.0.0-preview.1.20120.4 116 04/01/2025
3.1.32 122 04/01/2025
3.1.31 124 04/01/2025
3.1.30 119 04/01/2025
3.1.29 125 04/01/2025
3.1.28 112 04/01/2025
3.1.27 129 04/01/2025
3.1.26 120 04/01/2025
3.1.25 123 04/01/2025
3.1.24 116 04/01/2025
3.1.23 135 04/01/2025
3.1.22 117 04/01/2025
3.1.21 128 04/01/2025
3.1.20 108 04/01/2025
3.1.19 98 04/01/2025
3.1.18 118 04/01/2025
3.1.17 120 04/01/2025
3.1.16 120 04/01/2025
3.1.15 118 04/01/2025
3.1.14 128 04/01/2025
3.1.13 132 04/01/2025
3.1.12 112 04/01/2025
3.1.11 127 04/01/2025
3.1.10 135 04/01/2025
3.1.9 124 04/01/2025
3.1.8 145 04/01/2025
3.1.7 129 04/01/2025
3.1.6 135 04/01/2025
3.1.5 132 04/01/2025
3.1.4 143 04/01/2025
3.1.3 116 04/01/2025
3.1.2 123 04/01/2025
3.1.1 97 04/01/2025
3.1.0 135 04/01/2025
3.1.0-preview3.19553.2 139 03/31/2025
3.1.0-preview2.19525.4 122 04/01/2025
3.1.0-preview1.19506.1 106 04/01/2025
3.0.3 127 04/01/2025
3.0.2 137 04/01/2025
3.0.1 112 04/01/2025
3.0.0 127 04/01/2025
3.0.0-rc1.19456.10 109 04/01/2025
3.0.0-preview9.19423.4 121 04/01/2025
3.0.0-preview8.19405.4 107 04/01/2025
3.0.0-preview7.19362.4 123 04/01/2025
3.0.0-preview6.19304.6 124 04/01/2025
3.0.0-preview5.19227.9 116 04/01/2025
3.0.0-preview4.19216.2 119 04/01/2025
3.0.0-preview3.19153.1 124 04/01/2025
3.0.0-preview.19074.2 130 04/01/2025
3.0.0-preview.18572.1 115 03/31/2025
2.2.0 143 04/01/2025
2.2.0-preview3-35497 130 04/01/2025
2.2.0-preview2-35157 118 04/01/2025
2.2.0-preview1-35029 118 04/01/2025
2.1.1 130 04/01/2025
2.1.0 131 04/01/2025
2.1.0-rc1-final 133 03/31/2025
2.1.0-preview2-final 122 03/31/2025