Skip to content

Commit 6d37dce

Browse files
authored
Merge pull request #14 from microsoft/update-appsettings-load
update-appsettings-load
2 parents e08465c + 822ea2a commit 6d37dce

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/Program.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ public class Program {
44
public static void Main(string[] args) {
55
var builder = WebApplication.CreateBuilder(args);
66

7-
builder.Configuration.AddJsonFile("/workspaces/hostsvc-position-config/appsettings.json", optional: true, reloadOnChange: true)
8-
.AddJsonFile("/workspaces/hostsvc-position/src/appsettings.json", optional: true, reloadOnChange: true)
9-
.AddJsonFile("/workspaces/hostsvc-position/src/appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true)
10-
.Build();
7+
// Load the configuration being supplicated by the cluster first
8+
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);
9+
10+
// Load any local appsettings incase they're overriding the cluster values
11+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false);
12+
13+
// Load any local appsettings incase they're overriding the cluster values
14+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);
1115

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

test/debugClient/Program.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ public class Program {
44
public static void Main(string[] args) {
55
var builder = WebApplication.CreateBuilder(args);
66

7-
builder.Configuration
8-
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
9-
.AddJsonFile("appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true);
7+
// Load the configuration being supplicated by the cluster first
8+
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);
9+
10+
// Load any local appsettings incase they're overriding the cluster values
11+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false);
12+
13+
// Load any local appsettings incase they're overriding the cluster values
14+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);
1015

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

test/integrationTests/TestSharedContext.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ public TestSharedContext() {
2424
if (_grpcHost != null) return;
2525

2626
var builder = WebApplication.CreateBuilder();
27-
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
27+
28+
// Load the configuration being supplicated by the cluster first
29+
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);
30+
31+
// Load any local appsettings incase they're overriding the cluster values
32+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false);
33+
34+
// Load any local appsettings incase they're overriding the cluster values
35+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);
36+
2837

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

0 commit comments

Comments
 (0)