I am trying to setup an Azure Function to run locally on my development environment. I wish to connect to a MongoDb database instance.
In my local.settings.json
file I have added:
"ConnectionStrings": {
"DB_CONNECT_STRING": "mongodb://localhost:27017/MyDatabase"
}
In my function I then have:
module.exports = function (context, myTimer) {
console.log(process.env.DB_CONNECT_STRING);
context.done();
};
process.env.DB_CONNECT_STRING
is undefined.
I assume I need to add some kind of prefix to the environment variable, but I can't find this documented anywhere. How do I specify a connection string and reference it in the function code?