gpt4 book ai didi

c# - 访问azure应用程序设置中的嵌套json应用程序设置返回null

转载 作者:行者123 更新时间:2023-12-03 02:28:55 25 4
gpt4 key购买 nike

我有一个 Azure Functions 项目,并且本地有一个包含以下 JSON 的 local.settings.json 文件:

"PushFile": {
"Location": "value",
"Port": 22
}

我可以得到像这样的值

_configuration.GetValue<string>("PushFile:Location");
_configuration.GetValue<int>("PushFile:Port");

所以本地一切都很好。在 Azure Function App 服务中,我添加了一个应用程序设置,如下所示

Name: PushFile
Value: {"Location":"value", "Port": 22}

但是,当我运行 Azure 中托管的函数时,值解析为 null。

我必须在代码或 Azure 中启用/打开某些功能吗?

最佳答案

评论是正确的。在 azure 函数的应用设置中,您应该将名称定义为 PushFile:LocationPushFile:Port,如下所示:

enter image description here

然后您可以使用以下代码来读取它们:

_configuration.GetValue<string>("PushFile:Location");
_configuration.GetValue<int>("PushFile:Port");

关于c# - 访问azure应用程序设置中的嵌套json应用程序设置返回null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65907072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com