Microsoft.Extensions.Http.Polly 11.0.0-preview.5.26302.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.
124
Microsoft.Extensions.Http.Resilience
Resilience mechanisms for HTTP Client.
127
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
125
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
127
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
129
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
130
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
135
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.
125
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
127
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
128
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.
130
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
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
140
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
144

.NET Standard 2.0

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