How to differentiate between .NET environment configurations with Preview 4? #2707
-
With Aspire Preview 3, I configured the launchsettings of the AppHost to have the default configuration, and a Prometheus environment: "http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16263"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:15100"
},
"prometheus": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Prometheus",
"DOTNET_ENVIRONMENT": "Prometheus",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16263"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:15100"
} With the AppHost, I decided on the app model configuration based on the environment: if (builder.Environment.IsPrometheus())
{
// add grafana, prometheus container
// and other resources
}
else
{
// add azure resources
} In the ServiceDefaults, I also used the environment name to decide if AppInsights or Grafana/Prometheus should be configured. With version aspire 8.0.0-preview.5.24156.15/8.0.100, the environment name is no longer forwarded from the AppHost to the projects started, I think with this change: #2257 How should this be done now? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The application's launch profile is what is relevant, not the apphost's launch profile. If you want to continue using that pattern I would suggest manually flowing that environment into each of your projects in the apphost. |
Beta Was this translation helpful? Give feedback.
-
@davidfowl I'm ok in switching to a different pattern. It was just convenient just to define a launch profile with the apphost, and the configuration flows automatically. If I understand this now correctly, I'm specifying launch profiles with the service projects to differ the configurations; and with the apphost project to orchestrate the different app models and pass the launch profile name with the AddProject method. Another option I'm now thinking about is to create multiple apphost projects for the different app model orchestrations, then a launch profile is not needed with the apphost. Thanks! |
Beta Was this translation helpful? Give feedback.
The application's launch profile is what is relevant, not the apphost's launch profile. If you want to continue using that pattern I would suggest manually flowing that environment into each of your projects in the apphost.