Im working with Azure functions and have a problem.
I declared a local.settings.json
file with my variables as follows:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"TopicEndpoint": "my endpoint"
}
}
This allows my azure function to read the settings using:
var config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
var myTopic = config["Values:TopicEndpoint"];
This allows me to publish and export my variables to the portal via:
func azure functionapp
publish myfunctionapp --publish-local-settings -i
However, upon publishing and verifying that the value is in the 'Application Settings' in the portal, the "Values:TopicEndpoint" doesn't exist.
In order to be able to access its value i have to put my variables directly under the json root:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
}
"TopicEndpoint": "my endpoint"
}
That way I can safely use config['TopicEndpoint']
both in my local development environment, as well as on Azure. However, this defeats the purpose of the --publish-local-settings -i
as it only exports the values found under the 'Values' key, so I have to create all my settings manually.
Do you know why this happens or if maybe Im missing something?