用 Node.js 编写的 Azure Functions 可以访问连接字符串吗? [英] Can Azure Functions written in Node.js access Connection Strings?

查看:31
本文介绍了用 Node.js 编写的 Azure Functions 可以访问连接字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure 函数应用的应用设置包含可在门户中设置的数据库连接字符串的值.在 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.js 中没有那么明显.使用 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 Functions 可以访问连接字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆