所以我有这个简单的代码来从本地工作的自定义配置中获取应用程序设置:
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = "My.config"; // This works locally but not on azure I think
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
AppSettingsSection section = (AppSettingsSection)config.GetSection("appSettings");
var test = section.Settings["test"].Value; // throws nullref
现在,我在另一个项目中拥有“My.config”,并设置为“始终复制”到构建目录,并且在使用 Azure-cli (localhost) 进行调试时它可以完美运行。事实上,我认为这以前可以在 Azure 中运行,但现在不行了?
有什么想法可以解决这个问题吗?非常感谢!
最佳答案
关于c# - 在azure函数中查找自定义.config文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49071520/