Skip to content

Commit

Permalink
Optional config/appsettings.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-benoit committed Feb 17, 2024
1 parent 255d8ba commit eb6fdbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;

var builder = WebApplication.CreateSlimBuilder(args);
builder.Configuration.AddJsonFile("config/appsettings.json", true, true);
builder.Configuration.AddEnvironmentVariables();
var app = builder.Build();

var message = builder.Configuration["MESSAGE"] ?? "Hello, World!";
var message = builder.Configuration["MESSAGE"] ?? "Hello, World! (from code)";
var podName = builder.Configuration["POD_NAME"];
var namespaceName = builder.Configuration["NAMESPACE_NAME"];

Expand Down
3 changes: 3 additions & 0 deletions app/config/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MESSAGE": "Hello, World! (from settingtesttest)"
}

0 comments on commit eb6fdbe

Please sign in to comment.