所以我有这个简单的代码来从本地工作的自定义配置获取appsettings:
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中工作但它不再存在了吗?
任何想法如何解决这一问题?非常感谢!