Skip to main content
This quickstart guide will help you create your first resilience pipeline with Polly and execute code with automatic retry and timeout handling.

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:
Then register your resilience pipeline:

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

Use ResiliencePipeline<TResult> when you need to handle results:

Multiple independent pipelines

Create different pipelines for different scenarios:
Pipeline instances are lightweight and can be reused across multiple executions. Create them once and store them for the lifetime of your application.