Microsoft.Extensions.Http.Polly 10.0.0
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.ResilienceorMicrosoft.Extensions.Http.Resilienceinstead.
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 configuringPolicyHttpMessageHandlermessage handlers as part of anHttpClientmessage handler pipelinePolicyHttpMessageHandler: ADelegatingHandlerimplementation that executes request processing surrounded by aPolly.PolicyPollyServiceCollectionExtensions: Provides convenience extension methods to registerPolly.Registry.IPolicyRegistry<string>andPolly.Registry.IReadOnlyPolicyRegistry<string>in a service collectionHttpRequestMessageExtensions: Provides extension methods forHttpRequestMessagePolly 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.
|
66 |
|
OpenIddict
Versatile OpenID Connect stack for .NET.
Note: this metapackage only references the generic core, server and validation packages.
To use these features on ASP.NET Core or OWIN/Katana/ASP.NET 4.x, reference the OpenIddict.AspNetCore or OpenIddict.Owin package.
|
65 |
|
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
|
64 |
|
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
|
65 |
|
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
|
67 |
|
OpenIddict.Client.SystemNetHttp
System.Net.Http integration package for the OpenIddict client services.
|
68 |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
|
64 |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
|
65 |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
|
66 |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
|
67 |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
|
69 |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
|
70 |
.NET Standard 2.0
- Microsoft.Extensions.Http (>= 10.0.0)
- Polly (>= 7.2.4)
- Polly.Extensions.Http (>= 3.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 10.0.0 | 9 | 11/12/2025 |
| 10.0.0-rc.2.25502.107 | 21 | 10/14/2025 |
| 10.0.0-rc.1.25451.107 | 26 | 09/09/2025 |
| 10.0.0-preview.7.25380.108 | 26 | 08/13/2025 |
| 10.0.0-preview.6.25358.103 | 42 | 07/15/2025 |
| 10.0.0-preview.5.25277.114 | 44 | 06/06/2025 |
| 10.0.0-preview.4.25258.110 | 48 | 05/15/2025 |
| 10.0.0-preview.3.25172.1 | 68 | 04/12/2025 |
| 10.0.0-preview.2.25164.1 | 59 | 03/31/2025 |
| 10.0.0-preview.1.25120.3 | 49 | 04/01/2025 |
| 9.0.11 | 4 | 11/12/2025 |
| 9.0.10 | 15 | 10/14/2025 |
| 9.0.9 | 28 | 09/09/2025 |
| 9.0.8 | 40 | 08/05/2025 |
| 9.0.7 | 44 | 07/09/2025 |
| 9.0.6 | 35 | 06/12/2025 |
| 9.0.5 | 56 | 05/16/2025 |
| 9.0.4 | 66 | 04/11/2025 |
| 9.0.3 | 55 | 04/01/2025 |
| 9.0.2 | 56 | 04/01/2025 |
| 9.0.1 | 69 | 04/01/2025 |
| 9.0.0 | 56 | 04/01/2025 |
| 9.0.0-rc.2.24474.3 | 57 | 04/01/2025 |
| 9.0.0-rc.1.24452.1 | 54 | 04/01/2025 |
| 9.0.0-preview.7.24406.2 | 55 | 04/01/2025 |
| 9.0.0-preview.6.24328.4 | 59 | 04/01/2025 |
| 9.0.0-preview.5.24306.11 | 54 | 04/01/2025 |
| 9.0.0-preview.4.24267.6 | 56 | 04/01/2025 |
| 9.0.0-preview.3.24172.13 | 57 | 04/01/2025 |
| 9.0.0-preview.2.24128.4 | 52 | 04/01/2025 |
| 9.0.0-preview.1.24081.5 | 57 | 04/01/2025 |
| 8.0.22 | 3 | 11/12/2025 |
| 8.0.21 | 24 | 10/14/2025 |
| 8.0.20 | 26 | 09/09/2025 |
| 8.0.19 | 33 | 08/05/2025 |
| 8.0.18 | 39 | 07/09/2025 |
| 8.0.17 | 38 | 06/12/2025 |
| 8.0.16 | 39 | 05/16/2025 |
| 8.0.15 | 56 | 04/10/2025 |
| 8.0.14 | 58 | 04/01/2025 |
| 8.0.13 | 58 | 04/01/2025 |
| 8.0.12 | 60 | 04/01/2025 |
| 8.0.11 | 53 | 04/01/2025 |
| 8.0.10 | 57 | 04/01/2025 |
| 8.0.8 | 67 | 04/01/2025 |
| 8.0.7 | 59 | 04/01/2025 |
| 8.0.6 | 60 | 04/01/2025 |
| 8.0.5 | 62 | 04/01/2025 |
| 8.0.4 | 56 | 04/07/2025 |
| 8.0.3 | 57 | 04/03/2025 |
| 8.0.2 | 56 | 04/01/2025 |
| 8.0.1 | 57 | 04/01/2025 |
| 8.0.0 | 49 | 04/01/2025 |
| 8.0.0-rc.2.23480.2 | 50 | 04/01/2025 |
| 8.0.0-rc.1.23421.29 | 54 | 04/01/2025 |
| 8.0.0-preview.7.23375.9 | 49 | 04/01/2025 |
| 8.0.0-preview.6.23329.11 | 58 | 04/01/2025 |
| 8.0.0-preview.5.23302.2 | 60 | 04/01/2025 |
| 8.0.0-preview.4.23260.4 | 60 | 04/01/2025 |
| 8.0.0-preview.3.23177.8 | 52 | 04/01/2025 |
| 8.0.0-preview.2.23153.2 | 61 | 04/01/2025 |
| 8.0.0-preview.1.23112.2 | 51 | 04/01/2025 |
| 7.0.20 | 59 | 04/01/2025 |
| 7.0.19 | 53 | 04/01/2025 |
| 7.0.18 | 59 | 04/01/2025 |
| 7.0.17 | 58 | 04/01/2025 |
| 7.0.16 | 60 | 04/01/2025 |
| 7.0.15 | 57 | 04/01/2025 |
| 7.0.14 | 60 | 04/01/2025 |
| 7.0.13 | 66 | 04/01/2025 |
| 7.0.12 | 55 | 04/01/2025 |
| 7.0.11 | 60 | 04/01/2025 |
| 7.0.10 | 52 | 04/01/2025 |
| 7.0.9 | 57 | 04/01/2025 |
| 7.0.8 | 62 | 04/01/2025 |
| 7.0.7 | 55 | 04/01/2025 |
| 7.0.5 | 59 | 04/01/2025 |
| 7.0.4 | 64 | 04/01/2025 |
| 7.0.3 | 48 | 04/01/2025 |
| 7.0.2 | 58 | 04/01/2025 |
| 7.0.1 | 52 | 04/01/2025 |
| 7.0.0 | 51 | 04/01/2025 |
| 7.0.0-rc.2.22476.2 | 59 | 04/01/2025 |
| 7.0.0-rc.1.22427.2 | 52 | 04/01/2025 |
| 7.0.0-preview.7.22376.6 | 54 | 04/01/2025 |
| 7.0.0-preview.6.22330.3 | 49 | 04/01/2025 |
| 7.0.0-preview.5.22303.8 | 49 | 04/01/2025 |
| 7.0.0-preview.4.22251.1 | 48 | 04/01/2025 |
| 7.0.0-preview.3.22178.4 | 54 | 04/01/2025 |
| 7.0.0-preview.2.22153.2 | 44 | 04/01/2025 |
| 7.0.0-preview.1.22109.13 | 53 | 04/01/2025 |
| 6.0.36 | 53 | 04/01/2025 |
| 6.0.35 | 55 | 04/01/2025 |
| 6.0.33 | 53 | 04/01/2025 |
| 6.0.32 | 61 | 04/01/2025 |
| 6.0.31 | 56 | 04/01/2025 |
| 6.0.30 | 60 | 04/01/2025 |
| 6.0.29 | 52 | 04/01/2025 |
| 6.0.28 | 62 | 04/01/2025 |
| 6.0.27 | 62 | 04/01/2025 |
| 6.0.26 | 63 | 04/01/2025 |
| 6.0.25 | 60 | 04/01/2025 |
| 6.0.24 | 53 | 04/01/2025 |
| 6.0.23 | 61 | 04/01/2025 |
| 6.0.22 | 53 | 04/01/2025 |
| 6.0.21 | 53 | 04/01/2025 |
| 6.0.20 | 57 | 04/01/2025 |
| 6.0.19 | 60 | 04/01/2025 |
| 6.0.18 | 52 | 04/01/2025 |
| 6.0.16 | 59 | 04/01/2025 |
| 6.0.15 | 55 | 04/01/2025 |
| 6.0.14 | 61 | 04/01/2025 |
| 6.0.13 | 56 | 04/01/2025 |
| 6.0.12 | 60 | 04/01/2025 |
| 6.0.11 | 59 | 04/01/2025 |
| 6.0.10 | 57 | 04/01/2025 |
| 6.0.9 | 56 | 04/06/2025 |
| 6.0.8 | 54 | 04/01/2025 |
| 6.0.7 | 62 | 04/01/2025 |
| 6.0.6 | 64 | 04/01/2025 |
| 6.0.5 | 61 | 04/01/2025 |
| 6.0.4 | 54 | 04/01/2025 |
| 6.0.3 | 58 | 04/01/2025 |
| 6.0.2 | 56 | 04/01/2025 |
| 6.0.1 | 71 | 04/01/2025 |
| 6.0.0 | 62 | 04/01/2025 |
| 6.0.0-rc.2.21480.10 | 63 | 04/01/2025 |
| 6.0.0-rc.1.21452.15 | 64 | 04/01/2025 |
| 6.0.0-preview.7.21378.6 | 58 | 04/01/2025 |
| 6.0.0-preview.6.21355.2 | 55 | 04/01/2025 |
| 6.0.0-preview.5.21301.17 | 59 | 04/01/2025 |
| 6.0.0-preview.4.21253.5 | 59 | 04/01/2025 |
| 6.0.0-preview.3.21201.13 | 54 | 04/01/2025 |
| 6.0.0-preview.2.21154.6 | 60 | 04/01/2025 |
| 6.0.0-preview.1.21103.6 | 52 | 04/07/2025 |
| 5.0.1 | 55 | 04/01/2025 |
| 5.0.0 | 57 | 04/01/2025 |
| 5.0.0-rc.2.20478.4 | 60 | 04/01/2025 |
| 5.0.0-rc.1.20451.7 | 49 | 04/01/2025 |
| 5.0.0-preview.8.20407.3 | 57 | 04/01/2025 |
| 5.0.0-preview.7.20365.4 | 53 | 04/01/2025 |
| 5.0.0-preview.6.20306.1 | 60 | 04/01/2025 |
| 5.0.0-preview.5.20278.3 | 54 | 04/01/2025 |
| 5.0.0-preview.4.20251.2 | 56 | 04/01/2025 |
| 5.0.0-preview.3.20215.2 | 53 | 04/01/2025 |
| 5.0.0-preview.2.20160.3 | 57 | 04/01/2025 |
| 5.0.0-preview.1.20120.4 | 52 | 04/01/2025 |
| 3.1.32 | 48 | 04/01/2025 |
| 3.1.31 | 52 | 04/01/2025 |
| 3.1.30 | 48 | 04/01/2025 |
| 3.1.29 | 57 | 04/01/2025 |
| 3.1.28 | 53 | 04/01/2025 |
| 3.1.27 | 55 | 04/01/2025 |
| 3.1.26 | 51 | 04/01/2025 |
| 3.1.25 | 61 | 04/01/2025 |
| 3.1.24 | 54 | 04/01/2025 |
| 3.1.23 | 59 | 04/01/2025 |
| 3.1.22 | 60 | 04/01/2025 |
| 3.1.21 | 58 | 04/01/2025 |
| 3.1.20 | 59 | 04/01/2025 |
| 3.1.19 | 47 | 04/01/2025 |
| 3.1.18 | 60 | 04/01/2025 |
| 3.1.17 | 60 | 04/01/2025 |
| 3.1.16 | 55 | 04/01/2025 |
| 3.1.15 | 53 | 04/01/2025 |
| 3.1.14 | 61 | 04/01/2025 |
| 3.1.13 | 52 | 04/01/2025 |
| 3.1.12 | 49 | 04/01/2025 |
| 3.1.11 | 62 | 04/01/2025 |
| 3.1.10 | 65 | 04/01/2025 |
| 3.1.9 | 52 | 04/01/2025 |
| 3.1.8 | 60 | 04/01/2025 |
| 3.1.7 | 66 | 04/01/2025 |
| 3.1.6 | 67 | 04/01/2025 |
| 3.1.5 | 63 | 04/01/2025 |
| 3.1.4 | 61 | 04/01/2025 |
| 3.1.3 | 61 | 04/01/2025 |
| 3.1.2 | 62 | 04/01/2025 |
| 3.1.1 | 43 | 04/01/2025 |
| 3.1.0 | 55 | 04/01/2025 |
| 3.1.0-preview3.19553.2 | 66 | 03/31/2025 |
| 3.1.0-preview2.19525.4 | 57 | 04/01/2025 |
| 3.1.0-preview1.19506.1 | 48 | 04/01/2025 |
| 3.0.3 | 55 | 04/01/2025 |
| 3.0.2 | 60 | 04/01/2025 |
| 3.0.1 | 65 | 04/01/2025 |
| 3.0.0 | 60 | 04/01/2025 |
| 3.0.0-rc1.19456.10 | 48 | 04/01/2025 |
| 3.0.0-preview9.19423.4 | 50 | 04/01/2025 |
| 3.0.0-preview8.19405.4 | 53 | 04/01/2025 |
| 3.0.0-preview7.19362.4 | 62 | 04/01/2025 |
| 3.0.0-preview6.19304.6 | 56 | 04/01/2025 |
| 3.0.0-preview5.19227.9 | 53 | 04/01/2025 |
| 3.0.0-preview4.19216.2 | 52 | 04/01/2025 |
| 3.0.0-preview3.19153.1 | 51 | 04/01/2025 |
| 3.0.0-preview.19074.2 | 53 | 04/01/2025 |
| 3.0.0-preview.18572.1 | 54 | 03/31/2025 |
| 2.2.0 | 57 | 04/01/2025 |
| 2.2.0-preview3-35497 | 56 | 04/01/2025 |
| 2.2.0-preview2-35157 | 57 | 04/01/2025 |
| 2.2.0-preview1-35029 | 56 | 04/01/2025 |
| 2.1.1 | 60 | 04/01/2025 |
| 2.1.0 | 52 | 04/01/2025 |
| 2.1.0-rc1-final | 55 | 03/31/2025 |
| 2.1.0-preview2-final | 53 | 03/31/2025 |