Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Azure Functions written in Node.js access Connection Strings?

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

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.

like image 266
Aidan Avatar asked Dec 08 '22 16:12

Aidan


2 Answers

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.

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.

like image 191
David Ebbo Avatar answered Jan 05 '23 01:01

David Ebbo


try

process.env['YOUR_APP_SETTING'];

Microsoft Documentation

like image 22
Allen Tellez Avatar answered Jan 05 '23 01:01

Allen Tellez