Closed NathanStrutz closed 3 weeks ago
I suspect this is by design. What's in VCAP_SERVICES
and VCAP_APPLICATION
(running on Cloud Foundry) overrules all other configurations. The reason is so that developers can safely use settings locally, without risking that they are accidentally used in production.
You can force things by adding the "vcap:application:application_name" configuration key.
If you're just concerned with the name sent to Eureka, you can set the Eureka:Instance:AppName
key, see https://docs.steeltoe.io/api/v3/discovery/netflix-eureka.html.
The key Spring:Application:Name
is pretty low priority, used as a fallback if nothing else is available.
Success - Yes! OK the only thing I had to do was this:
Set an environment variable for Eureka:Instance:AppName
with the value myapp
. The discovery client recognizes this when the service starts up and registers the application with that different name.
Thank you!
BTW I wish this were better documented as a capability. I had a very hard time finding it.
Question
Spring:Application:Name
looks like it is being ignored in the Eureka discovery client. Unsure if I'm doing something wrong or if the configuration is really just not working.Background
This is a yarp service that stands as the incoming face of traffic to my other services. It, in turn, is registered in a Eureka reverse proxy to our parent org. I'm replacing the existing "myapp-gateway" with this service, "myapp-reverseproxy" (name changed for professional reasons).
"myapp-gateway"
registered as"myapp"
using Steeltoe 2.5.5 on .NET 8 upgraded from 3.1"myapp"
so I can swap services without upstream reconfiguration"myapp-reverseproxy"
The only real difference I can tell is the Steeltoe version change, and the move from Ocelot to Yarp which is mostly unrelated.
What I've done
SPRING_APPLICATION_NAME
andSpring:Application:Name
just trying thingsappsettings.json current state (snippet):
I confirmed this works by
Console.WriteLine(Configuration["spring:application:name"]);
before and after discovery client initialization. Without any env variables running locally it reads this as "myapp" precisely as expected, however this name is not being picked up by the Eureka client when it's running in TAS.I added every possible relevant package from the demos and the Steeltoe Initializr into my csproj file:
I tried a variety of ways to initialize the client to register with Eureka; here is the current state:
This does successfully register with Eureka, but it uses the application service name, I'm guessing it's the one injected in application_env_json:VCAP_APPLICATION. Once running, it sends continual service registration events to the injected Eureka instance as expected, but the application name is always myapp-reverseproxy and never myapp. Here's an example log message of a successful up message with the wrong service name:
The Ask
So first off, what am I doing wrong, or is Steeltoe broken?
Second, is there a programmatic way to set this in my Program.cs while the app is starting up so that I can make very sure that it has the correct configuration?
Environment (please complete the following information):
Additional context or links
Add any other context about the problem here.