简体   繁体   中英

Finding custom .config file in azure function?

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!

You'll need to configure these in the Azure portal using the application settings:

应用程序设置

All the settings here will overwirte whatever you had in either your web/app.config or your local.settings.json:

appsettings2

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM