Open samsp-msft opened 2 months ago
I think this is the same as https://github.com/dotnet/aspire/issues/1053
The appsettings.json part of this is indeed #1053.
For the environment variables part, it would be pretty easy to create an extension method that adds an environment variable to all project/container resources in the application model (or based on a predicate) using a lifecycle hook.
using a lifecycle hook.
Even easier in 8.2 using the new eventing model!
#pragma warning disable ASPIREEVENTING001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
builder.Eventing.Subscribe<BeforeStartEvent>((data, token) =>
{
foreach (var service in data.Model.Resources)
{
}
return Task.CompletedTask;
});
Background
In .NET 8 we added support for specifying the metrics you want exposed using config. We have not done much with the feature today.
Currently its less usable in Aspire than adding them in code, because with code you can do it once in ServiceDefaults, and it will apply to every project.
If I want to do it with config files, then I need to put it into the config file for each project in the Aspire solution.
Similarly if I want to apply an environment variable to each project - like our favorite Application Insights connection string, then I need to add it to each project in the AppHost.
Feature Request
appsettings.global.json
that will be overlaid on each project that is launched/deployed via the AppHost.