Prerequisites
- .NET 6.0 or later
- Basic understanding of C# and async/await
Step 1: Install Polly.Core
1
Add the package
Install the Polly.Core package using the .NET CLI:
2
Verify installation
The package should now appear in your project file:
Step 2: Create your first resilience pipeline
Create a resilience pipeline that combines retry and timeout strategies:The pipeline executes strategies in the order they are added. In this example, timeout wraps retry, which wraps your callback.
Step 3: Configure advanced retry behavior
Customize the retry strategy with exponential backoff and jitter:Step 4: Use dependency injection (optional)
For ASP.NET Core and other DI-enabled applications, install Polly.Extensions:Complete example: HTTP client with resilience
Here’s a complete example showing how to use Polly with HttpClient in an ASP.NET Core application:What’s next?
Core Concepts
Learn about resilience pipelines and strategies in depth
Resilience Strategies
Explore all available resilience strategies
Dependency Injection
Advanced DI patterns and configuration
Telemetry
Monitor your resilience pipelines
Common patterns
Generic pipelines for typed results
UseResiliencePipeline<TResult> when you need to handle results: