问题描述
Azure Function应用程序的应用程序设置"包含可在门户中设置的数据库连接字符串的值.在C#中,可以使用
The App Settings for an Azure Function App contain values for database connection strings that can be set in the portal. In C# they can be accessed using
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
对于用JavaScript编写的Azure函数,是否存在可以访问连接字符串的等效构造?我知道它们可以存储在应用程序设置中,但是由于门户网站上有专门讨论连接字符串的部分,所以我要问这是否对Node.js函数有任何应用程序.
For an Azure Function written in JavaScript, is there an equivalent construction that has access to the connection strings? I understand that they can be stored in the application settings, but since there is a section on the portal devoted to connection strings, I am asking if this has any application to Node.js functions.
推荐答案
在.NET中,应用程序设置和连接字符串之间的区别是有意义的,但在Node中却没有那么多.使用Node时,建议对所有秘密和连接字符串使用应用程序设置.您可以使用process.env.YourAppSetting
访问他们.
The distinction between app settings and connection strings makes sense in .NET, but not as much in Node. When using Node, the suggestion is to use app settings for all your secrets and connection strings. You can them access them using process.env.YourAppSetting
.
要直接回答您的问题,没有简单的方法来访问Node中的连接字符串,除非您开始对不能保证永远工作的前缀进行假设.
And to answer your question directly, there is no easy way to access connection strings in Node, unless you start making assumptions on prefixes that are not guaranteed to work forever.
这篇关于用Node.js编写的Azure函数可以访问连接字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!