i have a appservice on azure that is running a .net core api.
in my appsettings.json file i have a section something similar to :
"Serilog": {
"LevelSwitches": { "$controlSwitch": "Information" },
"MinimumLevel": {
"ControlledBy": "$controlSwitch",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "LOGS\\log.json",
"rollingInterval": "Day",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
}
},
{
"Name": "Seq",
"Args": {
"serverUrl": "https://MyLoggingServer",
"apiKey": "AAAAAAAAAAAAAAAAA",
"controlLevelSwitch": "$controlSwitch"
}
}
]}
In azure appsetting section on the azure portal i'm not sure how i would go about setting the apiKey, in other more simple settings i have another section in appsettings.json
"CustomSettings": {
"MySpecificSetting": "ABCDEFG",
}
Then in azure portal i have been able to set the setting by doing the following
CustomSettings:MySpecificSetting
but i'm not sure how this syntax would allow me to access the specific item in the writeTo array
Thanks for any help
you use : to nest:keys:down
cross platform you use __ to nest__keys__down (since : are bad for envars in *nix)
the key thing is it's not azure doing anything special... azure just sets env vars for the app from there. it's .net core config that's actually looking at the env vars and doing special things see https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-3.1#hierarchical-configuration-data & https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/index?tabs=basicconfiguration&view=aspnetcore-3.1#environment-variables-configuration-provider
As per this article, you would have to use syntax something like "CustomSettings__MySpecificSetting".
Hope this helps!! Cheers!! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With