簡體   English   中英

在 azure 函數中查找自定義 .config 文件?

[英]Finding custom .config file in azure function?

所以我有這個簡單的代碼來從本地工作的自定義配置中獲取 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 中工作過,但現在不再適用了?

任何想法如何解決這一問題? 非常感謝!

您需要使用應用程序設置在 Azure 門戶中配置這些:

應用程序設置

此處的所有設置都會覆蓋您在 web/app.config 或 local.settings.json 中的任何內容:

appsettings2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM