Using the new .NET Aspire Let's explore a scenario involving two web apps: the main app, and the login app:
var login = builder.AddProject<Projects.LoginApp_Web>("login");
builder.AddProject<Projects.AspireApp_Web>("main-app")
.WithReference(login); // not sure if will be need it
Questions:
It seems the ServiceDiscovery is the responsible for that, but I am not able to figure it out how to use it.
Thank you @AkalankaDissanayake,
.WithReference(login);
instead need to get http
or https
url and save it in app Environment.mainApp.WithEnvironment("LoginUrl", login.GetEndpoint("http"));
// Similarly you can do the other way around as well.
login.WithEnvironment("mainAppUrl", mainApp.GetEndpoint("http"));
var configuration = builder.Configuration;
configuration.GetRequiredValue("LoginUrl");
// which get the value from here:
configuration[name]
Original code: