Is it possible to use an appsettings.json file in Azure Functions?
There is documentation for environment variables here..
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#environment-variables
..however we use Octopus for deployments and would really like to have appsettings version controlled.
We have tried using
{
"frameworks": {
"net46": {
"dependencies": {
"Microsoft.Extensions.Configuration": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0"
}
}
}
}
but constantly get
2016-11-23T15:27:03.811 (12,16): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0
Even being able to supply/update environment variables via Octopus would be sufficient for our needs.
Please advise.
Only environment variables are supported for app settings and connection strings. appsettings.json
is not supported.
However, you can use Azure Resource Manager (ARM) Templates to configure the settings for your Function App. Here's a blog post that describe this in more detail.
For your needs the answer is YES! Azure Functions can use appsettings.json for your configurations. But there are some ordering sequence that Azure will do when a Function is requested.
1º) Azure will look for that KEYS that you used on .GetEnvironmentVariables("[KEY]") method, through Keys that were configured on Application Settings blade in Azure Functions settings
2º) If Azure wasn't able to find out that configurations through Application Settings keys, then Azure will try looking for after appsettings.json file into your root folder of the Function that you working on.
3º) Finally, if Azure wasn't able to find out this keys either on Application Settings neither on appsettings.json file, then Azure will do the last attempt to find out web.config for looking for into this file appsettings section keys.
For your appreciation, you'll able to find out these configurations by the sample on my github repo: here and here
I hope that these information help you.
According to the changes made to the configuration files, you should only use local.settings.json since the appsettings.json was renamed to local.settings.json
Reference to the change:
azure-functions-cli
For dependencies you should use/create the project.json inside your function. There you can specify your dependencies.
Please check:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#package-management
For example:
{
"frameworks": {
"net46":{
"dependencies": {
"Microsoft.ProjectOxford.Face": "1.1.0"
}
}
}
}