Microsoft.Extensions.Http.Polly 10.0.6

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
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
20
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
18
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
17
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
16
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
15
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services.
14

.NET Standard 2.0

Version Downloads Last updated
11.0.0-preview.3.26207.106 7 04/17/2026
11.0.0-preview.2.26159.112 11 03/13/2026
11.0.0-preview.1.26104.118 12 02/11/2026
10.0.7 0 04/21/2026
10.0.6 6 04/16/2026
10.0.5 9 03/13/2026
10.0.4 10 03/13/2026
10.0.3 13 02/11/2026
10.0.2 19 01/15/2026
10.0.1 19 12/10/2025
10.0.0 18 12/14/2025
10.0.0-rc.2.25502.107 12 12/19/2025
10.0.0-rc.1.25451.107 12 12/11/2025
10.0.0-preview.7.25380.108 11 12/19/2025
10.0.0-preview.6.25358.103 13 12/11/2025
10.0.0-preview.5.25277.114 11 12/11/2025
10.0.0-preview.4.25258.110 9 12/11/2025
10.0.0-preview.3.25172.1 15 12/21/2025
10.0.0-preview.2.25164.1 13 12/14/2025
10.0.0-preview.1.25120.3 15 12/18/2025
9.0.15 6 04/16/2026
9.0.14 10 03/13/2026
9.0.13 13 02/11/2026
9.0.12 22 01/15/2026
9.0.11 17 12/14/2025
9.0.10 14 12/19/2025
9.0.9 16 12/14/2025
9.0.8 16 12/09/2025
9.0.7 16 12/11/2025
9.0.6 18 12/12/2025
9.0.5 13 12/25/2025
9.0.4 10 12/20/2025
9.0.3 10 12/23/2025
9.0.2 12 12/14/2025
9.0.1 16 12/11/2025
9.0.0 16 12/19/2025
9.0.0-rc.2.24474.3 14 12/11/2025
9.0.0-rc.1.24452.1 12 12/21/2025
9.0.0-preview.7.24406.2 16 12/14/2025
9.0.0-preview.6.24328.4 10 12/14/2025
9.0.0-preview.5.24306.11 12 12/15/2025
9.0.0-preview.4.24267.6 15 12/15/2025
9.0.0-preview.3.24172.13 11 12/22/2025
9.0.0-preview.2.24128.4 11 12/21/2025
9.0.0-preview.1.24081.5 11 12/21/2025
8.0.26 6 04/16/2026
8.0.25 10 03/13/2026
8.0.24 14 02/12/2026
8.0.23 17 01/15/2026
8.0.22 16 12/14/2025
8.0.21 14 12/19/2025
8.0.20 17 12/11/2025
8.0.19 14 12/12/2025
8.0.18 15 12/13/2025
8.0.17 13 12/14/2025
8.0.16 13 12/22/2025
8.0.15 10 12/14/2025
8.0.14 13 12/18/2025
8.0.13 12 12/22/2025
8.0.12 14 12/11/2025
8.0.11 12 12/20/2025
8.0.10 18 12/10/2025
8.0.8 14 12/21/2025
8.0.7 13 12/13/2025
8.0.6 16 12/11/2025
8.0.5 16 12/17/2025
8.0.4 9 12/21/2025
8.0.3 15 12/16/2025
8.0.2 11 12/16/2025
8.0.1 13 12/16/2025
8.0.0 8 12/24/2025
8.0.0-rc.2.23480.2 16 12/15/2025
8.0.0-rc.1.23421.29 17 12/21/2025
8.0.0-preview.7.23375.9 14 12/14/2025
8.0.0-preview.6.23329.11 13 12/21/2025
8.0.0-preview.5.23302.2 12 12/15/2025
8.0.0-preview.4.23260.4 13 12/21/2025
8.0.0-preview.3.23177.8 10 12/15/2025
8.0.0-preview.2.23153.2 11 12/13/2025
8.0.0-preview.1.23112.2 15 12/21/2025
7.0.20 12 12/17/2025
7.0.19 13 12/20/2025
7.0.18 19 12/21/2025
7.0.17 11 12/18/2025
7.0.16 13 12/20/2025
7.0.15 15 12/23/2025
7.0.14 11 12/22/2025
7.0.13 12 12/27/2025
7.0.12 16 12/29/2025
7.0.11 12 12/20/2025
7.0.10 13 12/23/2025
7.0.9 14 12/20/2025
7.0.8 12 12/15/2025
7.0.7 12 12/14/2025
7.0.5 17 12/14/2025
7.0.4 13 12/14/2025
7.0.3 17 12/14/2025
7.0.2 18 12/22/2025
7.0.1 12 12/15/2025
7.0.0 13 12/10/2025
7.0.0-rc.2.22476.2 13 12/19/2025
7.0.0-rc.1.22427.2 15 12/21/2025
7.0.0-preview.7.22376.6 11 12/14/2025
7.0.0-preview.6.22330.3 15 12/21/2025
7.0.0-preview.5.22303.8 14 12/10/2025
7.0.0-preview.4.22251.1 39 12/15/2025
7.0.0-preview.3.22178.4 11 12/18/2025
7.0.0-preview.2.22153.2 13 12/14/2025
7.0.0-preview.1.22109.13 14 12/14/2025
6.0.36 17 12/22/2025
6.0.35 12 12/11/2025
6.0.33 15 12/14/2025
6.0.32 9 12/14/2025
6.0.31 11 12/15/2025
6.0.30 14 12/14/2025
6.0.29 12 12/20/2025
6.0.28 11 12/14/2025
6.0.27 9 12/14/2025
6.0.26 11 12/22/2025
6.0.25 8 12/22/2025
6.0.24 13 12/17/2025
6.0.23 16 12/11/2025
6.0.22 13 12/20/2025
6.0.21 13 12/23/2025
6.0.20 11 12/20/2025
6.0.19 15 12/20/2025
6.0.18 15 12/17/2025
6.0.16 13 12/20/2025
6.0.15 14 12/20/2025
6.0.14 13 12/14/2025
6.0.13 13 12/24/2025
6.0.12 15 12/14/2025
6.0.11 15 12/21/2025
6.0.10 16 12/14/2025
6.0.9 11 12/21/2025
6.0.8 11 12/15/2025
6.0.7 10 12/19/2025
6.0.6 15 12/15/2025
6.0.5 15 12/24/2025
6.0.4 14 12/14/2025
6.0.3 15 12/21/2025
6.0.2 12 12/17/2025
6.0.1 14 12/15/2025
6.0.0 16 12/20/2025
6.0.0-rc.2.21480.10 10 12/21/2025
6.0.0-rc.1.21452.15 13 12/14/2025
6.0.0-preview.7.21378.6 7 01/16/2026
6.0.0-preview.6.21355.2 16 12/14/2025
6.0.0-preview.5.21301.17 18 12/11/2025
6.0.0-preview.4.21253.5 12 12/14/2025
6.0.0-preview.3.21201.13 13 12/21/2025
6.0.0-preview.2.21154.6 14 12/15/2025
6.0.0-preview.1.21103.6 11 12/21/2025
5.0.1 12 12/21/2025
5.0.0 12 12/18/2025
5.0.0-rc.2.20478.4 16 12/21/2025
5.0.0-rc.1.20451.7 15 12/15/2025
5.0.0-preview.8.20407.3 12 12/16/2025
5.0.0-preview.7.20365.4 16 12/21/2025
5.0.0-preview.6.20306.1 10 12/20/2025
5.0.0-preview.5.20278.3 16 12/21/2025
5.0.0-preview.4.20251.2 8 12/14/2025
5.0.0-preview.3.20215.2 15 12/15/2025
5.0.0-preview.2.20160.3 13 12/14/2025
5.0.0-preview.1.20120.4 14 12/15/2025
3.1.32 17 12/23/2025
3.1.31 17 12/16/2025
3.1.30 15 12/21/2025
3.1.29 14 12/14/2025
3.1.28 16 12/14/2025
3.1.27 15 12/11/2025
3.1.26 20 12/14/2025
3.1.25 14 12/22/2025
3.1.24 13 12/17/2025
3.1.23 10 12/21/2025
3.1.22 12 12/16/2025
3.1.21 12 12/21/2025
3.1.20 15 12/14/2025
3.1.19 11 12/12/2025
3.1.18 14 12/24/2025
3.1.17 11 12/19/2025
3.1.16 13 12/21/2025
3.1.15 13 12/21/2025
3.1.14 16 12/15/2025
3.1.13 14 12/21/2025
3.1.12 13 12/14/2025
3.1.11 16 12/17/2025
3.1.10 17 12/21/2025
3.1.9 15 12/12/2025
3.1.8 14 12/21/2025
3.1.7 12 12/18/2025
3.1.6 15 12/18/2025
3.1.5 13 12/14/2025
3.1.4 10 12/21/2025
3.1.3 14 12/11/2025
3.1.2 11 12/12/2025
3.1.1 15 12/15/2025
3.1.0 11 12/10/2025
3.1.0-preview3.19553.2 13 12/21/2025
3.1.0-preview2.19525.4 10 12/21/2025
3.1.0-preview1.19506.1 14 12/21/2025
3.0.3 16 12/23/2025
3.0.2 12 12/12/2025
3.0.1 13 12/15/2025
3.0.0 17 12/21/2025
3.0.0-rc1.19456.10 14 12/16/2025
3.0.0-preview9.19423.4 10 12/21/2025
3.0.0-preview8.19405.4 10 12/21/2025
3.0.0-preview7.19362.4 15 12/14/2025
3.0.0-preview6.19304.6 10 12/16/2025
3.0.0-preview5.19227.9 13 12/16/2025
3.0.0-preview4.19216.2 10 12/14/2025
3.0.0-preview3.19153.1 14 12/21/2025
3.0.0-preview.19074.2 12 12/15/2025
3.0.0-preview.18572.1 13 12/21/2025
2.2.0 17 12/11/2025
2.2.0-preview3-35497 15 12/21/2025
2.2.0-preview2-35157 11 12/14/2025
2.2.0-preview1-35029 11 12/23/2025
2.1.1 16 12/11/2025
2.1.0 12 12/12/2025
2.1.0-rc1-final 17 12/16/2025
2.1.0-preview2-final 16 12/13/2025