1

I have a scenario where I would like to use YARP and be able to change the configuration (in this case the Address of a destination within a cluser) during runtime, is this possible?.

The idea is that we have an application that runs as two instances. Node1-For testing Node2-Production

When we are done testing in Node1 and ready for release to Production, I would like to redirect all traffic to Node1, and make Node2 our testing-node.. and next time we do the samething but this time Node1 goes back to testing and Node2 gets set for Production.

This scenario is fully possible to achive using YARP and by simply updating the appSettings.json, however.. I would really like to be able to do this dynamically using some sort of "internal" API of YARP. The idea is to expose this as a "REST-API" (HTTP-API/RPC) so we can switch between nodes using our CD-pipeline.

I have tried to google the net, and also done a quick peek into the source-code of YARP, but cant really find anything that mentions that changing the configuration during runtime/dynamically would be possible, since everything appears to be "ReadOnly".. any ideas?

Inx51
  • 1,911
  • 3
  • 24
  • 44

1 Answers1

0

Here's an example of that: https://medium.com/swlh/building-a-fast-and-reliable-reverse-proxy-with-yarp-4f70daf47300

Basically the solution is to implement IProxyConfigProvider

A version of this is built into Yarp now as well: https://github.com/microsoft/reverse-proxy/blob/main/src/ReverseProxy/Configuration/InMemoryConfigProvider.cs

Zout
  • 821
  • 10
  • 18