Azure functions - using appsettings.json

Can I use the appsettings.json file in Azure Functions?

There is documentation for environment variables.

https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#environment-variables

.. however we are using Octopus for deployment and would really like to have a version version of appsettings.

We tried to use

{ "frameworks": { "net46": { "dependencies": { "Microsoft.Extensions.Configuration": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0" } } } } 

but keep getting

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 the assembly link "System.Runtime, Version = 4.0.0.0

Even in order to provide / update environment variables through Octopus, it would be enough for our needs.

Please inform.

+6
source share
4 answers

Only environment variables for application parameters and connection strings are supported. appsettings.json not supported.

However, you can use the Azure Resource Manager (ARM) Management Templates to configure the settings for your application. Here 's a blog post that describe it in more detail.

+2
source

For your needs, the answer is YES! Azure functions can use appsettings.json for your configurations. But there is a sequencing sequence that Azure will execute when the function is requested.

1º) Azure will look for this KEYS that you used in .GetEnvironmentVariables ("[ KEY ]") using the keys that were configured on the app settings click in Azure Function Settings

2º) If Azure could not find out which configurations using the Application Settings keys, Azure will try to find the appsettings.json file in your root folder of the function you are working on.

3º) Finally, if Azure could not find these keys either in the application settings or in the appsettings.json file, then Azure will make its last attempt to find web.config to search in this appsettings file.

For your assessment, you will be able to learn these configurations from the model in my github registry: here and here

I hope this information helps you.

+7
source

According to the changes made to the configuration files, you should use local.settings.json since appsettings.json has been renamed local.settings.json

Change Link: azure-functions-cli

+7
source

For dependencies you should use / create 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 instance:

 { "frameworks": { "net46":{ "dependencies": { "Microsoft.ProjectOxford.Face": "1.1.0" } } } } 
0
source

Source: https://habr.com/ru/post/1012596/


All Articles