You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most of the scenarios where I've used YARP, I've found it useful to copy in a class I borrowed from another sample created during the Project Tye era that would read in values from IConfiguration to be pumped into the route and cluster endpoint values. In an example by Shayne Boyer, which I've mimicked in the CustomConfigFilterclass I created for the Build 2023 cloud native .NET demo code, a configuration-driven filter would give developers a conventional way of mapping environment variables to placeholders in their YARP configuration.
Take the appsettings.json code below, from the same Build 2023 demo repo:
In this code, the ORDERS_API and STORE_UI values are hard-coded in the file as settings, so they'll be read in from here by default or from environment variables. The placeholders {{ORDERS_API}} and {{STORE_UI}} are replaced with the values in these settings or environment variables at runtime, making it easy for developers to use environment variables to route traffic between services. It also gives developers who want to integrate things like Tye with YARP to create new service discovery approaches.
I'll follow this issue up with a pull request to add the filter to the product's code.
The text was updated successfully, but these errors were encountered:
It seems like you're doing 1:1 mapping of route patterns to destinations without any of the other features like health checks, load balancing, etc. In that case the new MapForwarder API might be more appropriate.
In most of the scenarios where I've used YARP, I've found it useful to copy in a class I borrowed from another sample created during the
Project Tye
era that would read in values fromIConfiguration
to be pumped into the route and cluster endpoint values. In an example by Shayne Boyer, which I've mimicked in theCustomConfigFilter
class I created for the Build 2023 cloud native .NET demo code, a configuration-driven filter would give developers a conventional way of mapping environment variables to placeholders in their YARP configuration.Take the
appsettings.json
code below, from the same Build 2023 demo repo:In this code, the
ORDERS_API
andSTORE_UI
values are hard-coded in the file as settings, so they'll be read in from here by default or from environment variables. The placeholders{{ORDERS_API}}
and{{STORE_UI}}
are replaced with the values in these settings or environment variables at runtime, making it easy for developers to use environment variables to route traffic between services. It also gives developers who want to integrate things like Tye with YARP to create new service discovery approaches.I'll follow this issue up with a pull request to add the filter to the product's code.
The text was updated successfully, but these errors were encountered: