Skip to content

Commit

Permalink
Merge pull request #13 from microsoft/update-appsettings-load
Browse files Browse the repository at this point in the history
updating appsettings load
  • Loading branch information
bradarm committed Aug 2, 2024
2 parents e3c85ea + 6ac6b3c commit e11e8e5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddJsonFile("/workspaces/hostsvc-sensor-config/appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("/workspaces/hostsvc-sensor/src/appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("/workspaces/hostsvc-sensor/src/appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true)
.Build();
// Load the configuration being supplicated by the cluster first
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);

// Load any local appsettings incase they're overriding the cluster values
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false);

// Load any local appsettings incase they're overriding the cluster values
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);

builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2))
.ConfigureServices((services) => {
Expand Down
11 changes: 8 additions & 3 deletions test/debugClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);

builder.Configuration
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true);
// Load the configuration being supplicated by the cluster first
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);

// Load any local appsettings incase they're overriding the cluster values
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false);

// Load any local appsettings incase they're overriding the cluster values
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);

builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2))
.ConfigureServices((services) => {
Expand Down
9 changes: 8 additions & 1 deletion test/integrationTests/TestSharedContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ public TestSharedContext() {
if (_grpcHost != null) return;

var builder = WebApplication.CreateBuilder();
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
// Load the configuration being supplicated by the cluster first
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);

// Load any local appsettings incase they're overriding the cluster values
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false);

// Load any local appsettings incase they're overriding the cluster values
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);

builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2))
.ConfigureServices((services) => {
Expand Down

0 comments on commit e11e8e5

Please sign in to comment.