So I have this simple code to get appsettings from a custom config that works locally:
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
Now, I have the "My.config" in another project, and is set to "copy always" to build directory and it works perfectly when debugging using Azure-cli (localhost). In fact, I think that this used to work in Azure before but it doesn't anymore?
Any ideas how to fix this? Thanks a lot!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.