0

I am creating azure function app in C# programming language. My app was compiling and running fine. Currently the target framework and function version is this

<TargetFramework>net462</TargetFramework>
<AzureFunctionsVersion>v1</AzureFunctionsVersion>

I want to updated it to

<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>

When I made this change, I had to upgrade the newtonsoft.json NuGet package from 9.0.1 to 11.0.2. After this I started getting this error in this code

string config= ConfigurationManager.AppSettings["configfileName"];
Error:
CS0103 C# The name 'ConfigurationManager' does not exist in the current context

I don't see an option to add reference to this dll. What are my options?

4

1 回答 1

1

Yes, off course you will meet this error. Feel free to use ConfigurationManager in azure function v1, but for function v2 and function v3, it is not supported.

You need to refer to environment variable, on local it is be setted in the 'Values' section of local.settings.json. On azure it is been setted in configuration settings tab.

Use this to get the settings:

System.Environment.GetEnvironmentVariable($"{parameterName}")

于 2020-09-30T02:23:18.550 回答