gpt4 book ai didi

node.js - 使用 Node 将 Azure App 设置作为对象获取?

转载 作者:搜寻专家 更新时间:2023-11-01 00:21:28 27 4
gpt4 key购买 nike

是否可以使用类似于 ASP.NET Core 的 Node/Express 将 Azure 中的应用程序设置视为对象?

例如,如果我的应用设置是:

container:value1 = "Hello",
container:value2 = "World"

我想得到一个“容器”的对象,它给我:

{
value1: "Hello",
value2: "World"
}

我试过像 ASP.NET Core 一样的 container:value1container__value1,但没有成功。

最佳答案

根据 Azure's documentation ,

App settings

This section contains name/value pairs that your web app will load on start up.

  • For .NET apps, these settings are injected into your .NET configuration AppSettings at runtime, overriding existing settings.
  • PHP, Python, Java and Node applications can access these settings as environment variables at runtime. For each app setting, two environment variables are created; one with the name specified by the app setting entry, and another with a prefix of APPSETTING_. Both contain the same value.

因此在 Node.js 中,您可以使用以下代码行来获取 Azure App Settings。

process.env['container:value1']

关于node.js - 使用 Node 将 Azure App 设置作为对象获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42373386/

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