I'm using appsettings.json
in my ASP.NET Core web application to provide configuration values to my application. Some of the configuration is more complex than just "name/value pairs", such as the Serilog configuration:
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"System": "Warning",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Authentication": "Information"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "C:/Development/logs/log-auth.txt",
"fileSizeLimitBytes": 1000000,
"rollOnFileSizeLimit": true,
"shared": true,
"flushToDiskInterval": 1,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} | {Message:lj}{NewLine}{Exception}"
}
}
]
}
What I want to know is, how can I provide my Azure web app with this configuration? I know I could create an appsettings.Production.json
file and push that when I publish, but what is the point in deploying settings with a publish? They might as well be hard-coded. The point of a settings file is that you should be able to change settings and restart the app, changing its behaviour, with no code re-deployment.
The only thing I can see provided by Azure is its "Settings | Configuration" section in the portal, but these settings are only allowed to be simple name/value pairs. My Serilog configuration is not valid there. So how can I provide any kind of advanced configuration?