seniorDependency Injection
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 pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro