Home > Back-end >  Precedence of Azure AppService settings?
Precedence of Azure AppService settings?

Time:06-29

My .NET Core 6 app service has the following setup inside Program.cs:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
//builder.Services.AddSingleton... ETC...
var app = builder.Build();

According to docs, it has a default precedence in case of different sources:

  1. Command-line arguments
  2. Non-prefixed environment variables
  3. User secrets
  4. appsettings.{Environment}.jsonappsettings.Production.json and appsettings.Development.json.
  5. appsettings.json

But I don't see if they mention where AppService settings from the Azure portal configuration get applied.

I expect that Azure portal settings for "MyKey1" would override any of the previous, but it is not happening.

Let's say, I have a appsettings.json with:

{ MyKey1 : "Value1" } 

and, in Azure site config:

MyKey1................Value2

When I deploy the app to the cloud it takes Value1 instead of Value2, for MyKey1.

Is this the normal behavior? What could I be doing wrong?

CodePudding user response:

App Settings get injected as Environment Variables. So I would assume they fall into position 2 of your list.

  • Related