无法访问 Azure 函数中的 appsettings.json 文件

Unable to access appsettings.json file in Azure function

我试图在 Azure Function 中访问我的 web.config 值,但后来我知道我们必须在 appsettings.json.

中添加配置值

我进行了这些更改并在 azure 函数位置上传了 appsettings.json,但没有成功。我的 azure 函数没有读取保存在 json 文件中的值。

请提出前进的方向。

您应该通过 Application settings 菜单项配置您的功能应用程序,请参阅 example

appsettings.json 或其他配置文件被忽略。

文件 local.settings.json 存储应用程序设置、连接字符串和 Azure Functions Core Tools 的设置。它具有以下结构:

{
      "IsEncrypted": false,   
      "Values": {
        "AzureWebJobsStorage": "<connection string>", 
        "AzureWebJobsDashboard": "<connection string>" 
      },
      "Host": {
        "LocalHttpPort": 7071, 
        "CORS": "*" 
      },
      "ConnectionStrings": {
        "SQLConnectionString": "Value"
      }
    }

我们可以从此 document.

获得有关本地设置文件的更多信息

These settings can also be read in your code as environment variables. In C#, use System.Environment.GetEnvironmentVariable or ConfigurationManager.AppSettings. In JavaScript, use process.env. Settings specified as a system environment variable take precedence over values in the local.settings.json file.