azure - 在函数执行过程中动态创建Azure函数中的AppSettings C#

标签 azure azure-functions

我正在使用预编译的 Azure Functions,并且我知道我可以使用 ConfigurationManager.AppSettings["keyname"] 读取应用程序设置中的值。

我一直在尝试使用如下内容创建额外的应用程序设置:

var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
settings.Add(pair.Key, pair.Value);

但是,当我尝试此操作时,我收到以下错误消息:

exePath must be specified when not running inside a stand alone exe. 

如果这可能的话,有什么想法吗?或者能够提供一个如何让它工作的指针?

最佳答案

Azure Functions 运行时配置文件不可写,但当它运行应用服务时,它会继承其支持的应用设置功能,该功能使您可以访问管理将作为应用程序设置和环境变量注入(inject)的设置通过门户运行时。

您可以通过 ARM 或 CLI 以编程方式管理这些设置。

请记住,对这些设置的更改将触发站点重新启动,因此根据您的情况,如果您需要动态更新的设置,您可能需要考虑使用不同的配置/设置源,包括缓存选项像 Redis 一样维护共享状态。

关于azure - 在函数执行过程中动态创建Azure函数中的AppSettings C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46530215/

相关文章:

Azure Web App - 无法加载文件或程序集 Microsoft.SqlServer.Types

.net - 如何创建可部署到 Azure 的 ZIP 包

python - Azure Functions Python V2 计时器触发器未部署,但在 VSCode 中状态成功

azure - 当 key 是公开的时,Azure 函数 API key 有什么意义吗?

function - 状态 : 503 Service Unavailable Azure Function

python - azure Blob : upload directory content using a loop in Python

azure - 将 Mosquitto 连接到新的 Azure MQTT 后端

azure - 在 Azure 数据工厂中使用本地数据网关

Azure - 从数据库动态获取计划并触发多种方法在azure中执行不同的任务?

Azure 耐用功能 想要高吞吐量/低延迟?