Create one settings file per environment, such as appsettings.Development.json and appsettings.Production.json, and set the environment name on each machine. At startup the app loads appsettings.json first, then the file for the current environment, whose keys override the base file.
The environment name comes from the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT variable. When neither is set, the app runs as Production. Locally, the launch profile in launchSettings.json usually sets it to Development.
Code can also branch on the environment:
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
Keep secrets out of these files. Production secrets belong in a controlled store such as Azure Key Vault.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓