c# - 如何读取 Azure Function 应用程序内的配置 json 文件

标签 c# .net-core azure-function-app

我有一个 json 配置文件,我想从 Azure 函数内部读取该文件。默认情况下,我们有 localsettings.json 文件,但我还需要一个 Json 配置文件来读取我的函数代码。最好的方法是什么,到目前为止,对于我的其他项目,我可以通过下面的代码阅读,但这在 Azure 函数内部不起作用。

 var builder = new ConfigurationBuilder()
        .SetBasePath(Path.Combine(Root))
        .AddJsonFile("DataFileConfiguration.json", optional: false);
         var config = builder.Build();
         var tableStorageOutput = new TableStorageConfiguration();
         config.GetSection("TableStorageRule").Bind(tableStorageOutput);

最佳答案

在解决方案资源管理器中右键单击“DataFileConfiguration.json”文件 ->“属性”->“复制到输出文件夹”=“始终复制”

enter image description here

关于c# - 如何读取 Azure Function 应用程序内的配置 json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64778036/

相关文章:

c# - 检测通用类型中的接口(interface)

c# backgroundWorker 不引发 ProgressChanged 或 RunWorkerCompleted 事件

c# - 在 aspnet core 运行时检查托管服务器是 IIS 还是 Kestrel

c# - 如何在 .net core 3.1 应用程序中访问 W3C TraceContext header ?

c# - 如何在http触发azure函数应用程序中添加自定义启动类

node.js - 在带有nodejs的azure函数应用程序中使用SSL证书

c# - 空字符串 ""何时是有效的日期时间字符串格式?

c# - 从 Excel 读取 NUnit 测试数据 - 如何访问测试数据?

azure - 使用 Azure MSI 访问 Azure 表存储

Azure 功能应用程序 - 从高级计划更改为应用程序服务计划