Skip to content

Commit 84103c7

Browse files
authored
Merge pull request #13 from microsoft/update-appsettings-load
Update appsettings load
2 parents 22ca779 + 7b0904f commit 84103c7

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/Program.cs

+8-3
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.AddJsonFile("/workspaces/platform-mts-config/appsettings.json", optional: true, reloadOnChange: true)
8-
.AddJsonFile("/workspaces/platform-mts/src/appsettings.json", optional: true, reloadOnChange: true)
9-
.AddJsonFile("/workspaces/platform-mts/src/appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true).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);
1015

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

test/debugClient/Program.cs

+8-3
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

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ public TestSharedContext() {
2222
if (_grpcHost != null) return;
2323

2424
var builder = WebApplication.CreateBuilder();
25-
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
25+
// Load the configuration being supplicated by the cluster first
26+
builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false);
27+
28+
// Load any local appsettings incase they're overriding the cluster values
29+
builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "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.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false);
2633

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

0 commit comments

Comments
 (0)