How to integrate Polly/Resilience policies via DI?

Updated Apr 28, 2026

Short answer

Resilience policies (retries, circuit breakers) should be injected as decorators or via named HTTP clients rather than hardcoded.

Deep explanation

Using HttpClientFactory combined with DI allows you to attach transient fault handling policies directly to specific typed clients. The consumer injects the interface, completely unaware that a circuit breaker is evaluating its failing network calls in the background.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Dependency Injection interview questions

View all →