From the course: .NET Microservices for Azure Developers

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Adding resilience traits to the microservice using Polly

Adding resilience traits to the microservice using Polly - Azure Tutorial

From the course: .NET Microservices for Azure Developers

Adding resilience traits to the microservice using Polly

- [Instructor] One of the drawbacks of synchronous communication is the potential reduction in availability as it involves multiple microservices. To address this, we can enhance resilience in our services using Polly. Polly is a .NET library designed for resilience and transient fault handling, allowing us to implement policies like automatic retry and circuit breaker. In .NET 8, we can use the Microsoft extensions Http.Resilience NuGet Package, which is based on the Polly library. So let's do that. Let's add a new NuGet package reference and the name is Microsoft.Extensions.Http.Resilience. Let's install it and let's go back to the program file and let's implement the code. Now, since we're communicating to the management microservice, this HTTP client object we're configuring here is a perfect location for implementing a resilience handler. So let's do that. I'm going to execute AddResilienceHandler, and I need to pass the name for this pipeline, say management-pipeline or…

Contents