Microsoft.Extensions.Http.Polly 10.0.0-preview.1.25120.3

Prefix Reserved
This is a prerelease version of Microsoft.Extensions.Http.Polly.
dotnet add package Microsoft.Extensions.Http.Polly --version 10.0.0-preview.1.25120.3                
NuGet\Install-Package Microsoft.Extensions.Http.Polly -Version 10.0.0-preview.1.25120.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.0-preview.1.25120.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Extensions.Http.Polly --version 10.0.0-preview.1.25120.3                
#r "nuget: Microsoft.Extensions.Http.Polly, 10.0.0-preview.1.25120.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Extensions.Http.Polly as a Cake Addin
#addin nuget:?package=Microsoft.Extensions.Http.Polly&version=10.0.0-preview.1.25120.3&prerelease

// Install Microsoft.Extensions.Http.Polly as a Cake Tool
#tool nuget:?package=Microsoft.Extensions.Http.Polly&version=10.0.0-preview.1.25120.3&prerelease                

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.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (774)

Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Http.Polly:

Package Downloads
OpenIddict.Validation.SystemNetHttp

System.Net.Http integration package for the OpenIddict validation services.

Rystem.OpenAi

.Net wrapper for OpenAI with Dependency injection integration, factory integration: you may inject more than one endpoint, azure integration: you may swap among openai endpoint and any azure endpoint quickly and easily. You can calculate tokens and cost for each request (before the request) and for each response. You can access to the dashboard api to retrieve your current or previous billing.

Rystem.RepositoryFramework.Api.Client

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

Omnia.Fx.NetCore

Package Description

OpenIddict.Client.SystemNetHttp

System.Net.Http integration package for the OpenIddict client services.

GitHub repositories (113)

Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.Http.Polly:

Repository Stars
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
RayWangQvQ/BiliBiliToolPro
B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。敏感肌也能用。
elsa-workflows/elsa-core
A .NET workflows library
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
Version Downloads Last updated
10.0.0-preview.1.25120.3 82 2/25/2025
9.0.2 241,251 2/11/2025
9.0.1 726,631 1/14/2025
9.0.0 2,493,628 11/12/2024
9.0.0-rc.2.24474.3 66,331 10/8/2024
9.0.0-rc.1.24452.1 32,039 9/10/2024
9.0.0-preview.7.24406.2 5,847 8/13/2024
9.0.0-preview.6.24328.4 18,686 7/9/2024
9.0.0-preview.5.24306.11 36,465 6/11/2024
9.0.0-preview.4.24267.6 6,034 5/21/2024
9.0.0-preview.3.24172.13 12,112 4/11/2024
9.0.0-preview.2.24128.4 18,271 3/12/2024
9.0.0-preview.1.24081.5 6,726 2/13/2024
8.0.13 138,061 2/11/2025
8.0.12 491,310 1/14/2025
8.0.11 2,109,999 11/12/2024
8.0.10 4,868,862 10/8/2024
8.0.8 6,050,805 8/13/2024
8.0.7 5,683,121 7/9/2024
8.0.6 6,194,991 5/28/2024
8.0.5 2,407,131 5/14/2024
8.0.4 4,995,189 4/9/2024
8.0.3 4,710,700 3/12/2024
8.0.2 4,247,574 2/13/2024
8.0.1 4,982,263 1/9/2024
8.0.0 8,841,741 11/14/2023
8.0.0-rc.2.23480.2 58,128 10/10/2023
8.0.0-rc.1.23421.29 31,215 9/12/2023
8.0.0-preview.7.23375.9 44,227 8/8/2023
8.0.0-preview.6.23329.11 23,377 7/11/2023
8.0.0-preview.5.23302.2 12,700 6/13/2023
8.0.0-preview.4.23260.4 206,920 5/16/2023
8.0.0-preview.3.23177.8 23,287 4/11/2023
8.0.0-preview.2.23153.2 25,276 3/14/2023
8.0.0-preview.1.23112.2 13,986 2/21/2023
7.0.20 374,949 5/28/2024
7.0.19 81,933 5/14/2024
7.0.18 266,921 4/9/2024
7.0.17 249,780 3/12/2024
7.0.16 379,200 2/13/2024
7.0.15 705,500 1/9/2024
7.0.14 1,455,995 11/14/2023
7.0.13 2,069,387 10/24/2023
7.0.12 5,726,576 10/10/2023
7.0.11 2,805,966 9/12/2023
7.0.10 4,535,096 8/8/2023
7.0.9 3,577,027 7/11/2023
7.0.8 1,690,602 6/22/2023
7.0.7 1,662,485 6/13/2023
7.0.5 8,581,712 4/11/2023
7.0.4 3,829,148 3/14/2023
7.0.3 2,885,981 2/14/2023
7.0.2 3,754,648 1/10/2023
7.0.1 2,407,203 12/13/2022
7.0.0 4,652,150 11/7/2022
7.0.0-rc.2.22476.2 21,958 10/11/2022
7.0.0-rc.1.22427.2 41,022 9/14/2022
7.0.0-preview.7.22376.6 33,631 8/9/2022
7.0.0-preview.6.22330.3 34,753 7/12/2022
7.0.0-preview.5.22303.8 11,723 6/14/2022
7.0.0-preview.4.22251.1 17,593 5/10/2022
7.0.0-preview.3.22178.4 9,375 4/13/2022
7.0.0-preview.2.22153.2 27,128 3/14/2022
7.0.0-preview.1.22109.13 7,006 2/17/2022
6.0.36 67,696 11/12/2024
6.0.35 112,754 10/8/2024
6.0.33 226,613 8/13/2024
6.0.32 186,495 7/9/2024
6.0.31 352,870 5/28/2024
6.0.30 94,402 5/14/2024
6.0.29 453,165 4/9/2024
6.0.28 457,985 3/12/2024
6.0.27 441,416 2/13/2024
6.0.26 1,135,537 1/9/2024
6.0.25 1,174,504 11/14/2023
6.0.24 663,495 10/24/2023
6.0.23 527,281 10/10/2023
6.0.22 780,845 9/12/2023
6.0.21 1,156,101 8/8/2023
6.0.20 1,016,465 7/11/2023
6.0.19 612,072 6/22/2023
6.0.18 539,506 6/13/2023
6.0.16 3,019,444 4/11/2023
6.0.15 1,326,574 3/14/2023
6.0.14 1,345,825 2/14/2023
6.0.13 2,090,505 1/10/2023
6.0.12 1,502,272 12/13/2022
6.0.11 2,476,857 11/7/2022
6.0.10 6,047,416 10/11/2022
6.0.9 5,371,968 9/13/2022
6.0.8 7,430,927 8/9/2022
6.0.7 5,431,401 7/12/2022
6.0.6 4,045,323 6/14/2022
6.0.5 4,921,614 5/10/2022
6.0.4 4,468,835 4/11/2022
6.0.3 4,587,866 3/8/2022
6.0.2 4,204,622 2/8/2022
6.0.1 6,598,080 12/14/2021
6.0.0 9,708,913 11/8/2021
6.0.0-rc.2.21480.10 35,462 10/12/2021
6.0.0-rc.1.21452.15 12,235 9/14/2021
6.0.0-preview.7.21378.6 16,825 8/10/2021
6.0.0-preview.6.21355.2 5,419 7/14/2021
6.0.0-preview.5.21301.17 12,688 6/15/2021
6.0.0-preview.4.21253.5 9,229 5/24/2021
6.0.0-preview.3.21201.13 10,897 4/8/2021
6.0.0-preview.2.21154.6 7,244 3/11/2021 6.0.0-preview.2.21154.6 is deprecated because it is no longer maintained.
6.0.0-preview.1.21103.6 25,763 2/12/2021 6.0.0-preview.1.21103.6 is deprecated because it is no longer maintained.
5.0.1 21,933,277 12/8/2020 5.0.1 is deprecated because it is no longer maintained.
5.0.0 4,314,321 11/9/2020 5.0.0 is deprecated because it is no longer maintained.
5.0.0-rc.2.20478.4 11,096 10/13/2020 5.0.0-rc.2.20478.4 is deprecated because it is no longer maintained.
5.0.0-rc.1.20451.7 8,855 9/14/2020 5.0.0-rc.1.20451.7 is deprecated because it is no longer maintained.
5.0.0-preview.8.20407.3 3,091 8/25/2020 5.0.0-preview.8.20407.3 is deprecated because it is no longer maintained.
5.0.0-preview.7.20365.4 10,420 7/21/2020 5.0.0-preview.7.20365.4 is deprecated because it is no longer maintained.
5.0.0-preview.6.20306.1 17,814 6/25/2020 5.0.0-preview.6.20306.1 is deprecated because it is no longer maintained.
5.0.0-preview.5.20278.3 3,944 6/10/2020 5.0.0-preview.5.20278.3 is deprecated because it is no longer maintained.
5.0.0-preview.4.20251.2 2,480 5/18/2020 5.0.0-preview.4.20251.2 is deprecated because it is no longer maintained.
5.0.0-preview.3.20215.2 10,355 4/23/2020 5.0.0-preview.3.20215.2 is deprecated because it is no longer maintained.
5.0.0-preview.2.20160.3 29,196 4/2/2020 5.0.0-preview.2.20160.3 is deprecated because it is no longer maintained.
5.0.0-preview.1.20120.4 4,162 3/16/2020 5.0.0-preview.1.20120.4 is deprecated because it is no longer maintained.
3.1.32 781,292 12/13/2022
3.1.31 142,113 11/8/2022
3.1.30 128,103 10/11/2022
3.1.29 133,614 9/13/2022
3.1.28 460,065 8/9/2022
3.1.27 105,712 7/12/2022
3.1.26 133,491 6/14/2022
3.1.25 299,666 5/10/2022
3.1.24 189,794 4/11/2022
3.1.23 239,547 3/8/2022
3.1.22 2,321,766 12/14/2021
3.1.21 705,660 11/7/2021
3.1.20 314,326 10/11/2021
3.1.19 514,528 9/14/2021
3.1.18 571,368 8/10/2021
3.1.17 990,878 7/13/2021
3.1.16 4,680,741 6/8/2021
3.1.15 1,151,135 5/11/2021
3.1.14 1,063,503 4/6/2021
3.1.13 3,059,118 3/9/2021
3.1.12 2,091,297 2/9/2021
3.1.11 680,819 1/12/2021
3.1.10 2,130,855 11/9/2020
3.1.9 2,923,447 10/13/2020
3.1.8 3,682,318 9/8/2020
3.1.7 5,402,849 8/11/2020
3.1.6 3,374,866 7/14/2020
3.1.5 4,962,937 6/9/2020
3.1.4 2,621,342 5/12/2020
3.1.3 3,354,756 3/24/2020
3.1.2 2,724,116 2/18/2020
3.1.1 3,150,806 1/14/2020
3.1.0 4,588,129 12/3/2019
3.1.0-preview3.19553.2 2,994 11/13/2019 3.1.0-preview3.19553.2 is deprecated because it is no longer maintained.
3.1.0-preview2.19525.4 1,558 11/1/2019 3.1.0-preview2.19525.4 is deprecated because it is no longer maintained.
3.1.0-preview1.19506.1 931 10/15/2019 3.1.0-preview1.19506.1 is deprecated because it is no longer maintained.
3.0.3 204,806 2/18/2020 3.0.3 is deprecated because it is no longer maintained.
3.0.2 45,023 1/14/2020 3.0.2 is deprecated because it is no longer maintained.
3.0.1 272,591 11/18/2019 3.0.1 is deprecated because it is no longer maintained.
3.0.0 2,688,612 9/23/2019 3.0.0 is deprecated because it is no longer maintained.
3.0.0-rc1.19456.10 6,207 9/16/2019 3.0.0-rc1.19456.10 is deprecated because it is no longer maintained.
3.0.0-preview9.19423.4 7,777 9/4/2019 3.0.0-preview9.19423.4 is deprecated because it is no longer maintained.
3.0.0-preview8.19405.4 4,617 8/13/2019 3.0.0-preview8.19405.4 is deprecated because it is no longer maintained.
3.0.0-preview7.19362.4 3,111 7/23/2019 3.0.0-preview7.19362.4 is deprecated because it is no longer maintained.
3.0.0-preview6.19304.6 4,064 6/12/2019 3.0.0-preview6.19304.6 is deprecated because it is no longer maintained.
3.0.0-preview5.19227.9 8,833 5/6/2019 3.0.0-preview5.19227.9 is deprecated because it is no longer maintained.
3.0.0-preview4.19216.2 1,104 4/18/2019 3.0.0-preview4.19216.2 is deprecated because it is no longer maintained.
3.0.0-preview3.19153.1 1,304 3/6/2019 3.0.0-preview3.19153.1 is deprecated because it is no longer maintained.
3.0.0-preview.19074.2 2,337 1/29/2019 3.0.0-preview.19074.2 is deprecated because it is no longer maintained.
3.0.0-preview.18572.1 2,033 12/4/2018 3.0.0-preview.18572.1 is deprecated because it is no longer maintained.
2.2.0 13,165,200 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 14,677 10/17/2018 2.2.0-preview3-35497 is deprecated because it is no longer maintained.
2.2.0-preview2-35157 6,318 9/12/2018 2.2.0-preview2-35157 is deprecated because it is no longer maintained.
2.2.0-preview1-35029 4,212 8/22/2018 2.2.0-preview1-35029 is deprecated because it is no longer maintained.
2.1.1 4,988,036 6/18/2018
2.1.0 2,288,259 5/29/2018
2.1.0-rc1-final 10,367 5/6/2018 2.1.0-rc1-final is deprecated because it is no longer maintained.
2.1.0-preview2-final 4,002 4/13/2018 2.1.0-preview2-final is deprecated because it is no longer maintained.