Azure connection string does not overwrite appsettings.json

394 Views Asked by At

I am using .NET 6.0, in the project I have appsettings.json file with the following line:

"ConnectionStrings": {
        "SqlConnection": "Server=.\\SQLEXPRESS;Database=XXX;Trusted_Connection=True;MultipleActiveResultSets=true"
},

In Azure I have Connection Strings defined as follows:[enter image description here]1

When I check appsettings.json in xxx.scm.azurewebsites.net/wwwroot I can see that it still uses ConnectionStrings defined in my project's appsetting.json but not in the Azure one.

My Dbcontext:

services.AddDbContext<MyContext>(
            options => options.UseSqlServer(Configuration.GetConnectionString("SqlConnection")));

How I get to Azure overwrite my connection string and use it instead? Thanks.

1

There are 1 best solutions below

4
silent On BEST ANSWER

The App Service will not change your appsettings.json file. It will inject any app settings (including Connection Strings) in addition to your appsettings.json file into your application (as ENV vars).