I'm using appsettings.json for the configuration of my Azure Function (netcoreapp3.1, running on a Windows machine).
In the appsettings.json file there is a array with settings:
{
"ArraySettings": [
{
"ArraySettingProperty1": "ArraySetting1Value1",
"ArraySettingProperty2": "ArraySetting1Property2"
},
{
"ArraySettingProperty1": "ArraySetting2Value1",
"ArraySettingProperty2": "ArraySetting2Property2"
}
],
"SingleSetting": "SingleValue"
}
It works fine if I run the Azure Function locally. But it seems not to work on Azure although the appsettings.json file was deployt and can be found by the Azure Function.
In Startup.cs:
private IConfiguration InitializeConfiguration(IFunctionsHostBuilder functionsHostBuilder)
{
ExecutionContextOptions executionContextOptions = functionsHostBuilder
.Services
.BuildServiceProvider()
.GetService<IOptions<ExecutionContextOptions>>()
.Value;
return new ConfigurationBuilder()
.SetBasePath(executionContextOptions.AppDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
}
This is what I already tried (without success):
Copying the settings to the Values section of the local.settings.json file
Adding the settings to the Application Settings on Azure (with and without commenting out the appsettings.json config) in the following key formats:
2.1 ArraySettings:ArraySettingProperty1:0
2.2 ArraySettings__ArraySettingsProperty1__0
2.3 Values__ArraySettings__ArraySettingsProperty1__0
Why do the array settings work locally but not on Azure? How can I make them work on Azure? Thanks!
Please try setting them like the following in configuration settings in your app service:
Key: ArraySettings__0__ArraySettingProperty1
Value: ArraySetting1Value1
Key: ArraySettings__0__ArraySettingProperty2
Value: ArraySetting1Value2
Key: ArraySettings__1__ArraySettingProperty1
Value: ArraySetting1Value1
Key: ArraySettings__1__ArraySettingProperty2
Value: ArraySetting1Value2
Key: SingleSetting
Value: SingleValue
If your app service is deployed on Windows, you can use : as a delimiter instead of __. However __ works on both Windows and Linux.
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