I've made an azure function in C#. I use local.settings.json for testing locally. Everything works correctly with
ConfigurationManager.Appsettings["key"]
Now I have published it. Nothing is working anymore. Host.json is there, I can browse the function app settings tab and I can see the configuration host.json right there with all the values.
Host.json format is the same as local.settings.json:
{
"IsEncrypted": false,
"Values": {
"MYCONFIG": "HEY",
"THEOTHERCONFIG" : "WHASSUP"
}
}
If I run locally everything is working fine. If I publish I get null in all the values.
I tried
ConfigurationManager.Appsettings["key"]
and
System.Environment.GetEnvironmentVariable("MYCONFIG", EnvironmentVariableTarget.Process);
Nothing works.
Microsoft documentation doesn't unveil the sacred secret of reading a config file.
Here I see they don't even mention a host.json file, they just say you have to manually put them in the azure portal.... which is higly impractical.
Any suggestion? Thank you