title: Reusing Database Connections With Azure Functions Using Javascript
body: <p>I cannot find clear information on how to manage database connections (MongoDB in my case) from an Azure function written in Javascript.  </p>
  
  <p>The Microsoft document below says to not create a connection for each invocation of the function by using static variables in C# using .NET Framework Data Provider for SQL Server and the pooling is handled by the client connection.  It does not describe how to do this in Javascript.</p>
  
  <p><a href="https://docs.microsoft.com/en-us/azure/azure-functions/manage-connections" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/azure-functions/manage-connections</a></p>
  
  <p>A solution of creating a global variable to hold the database client between invocations is described here but the author is not confident this is the correct way to do it.</p>
  
  <p><a href="http://thecodebarbarian.com/getting-started-with-azure-functions-and-mongodb.html" rel="nofollow noreferrer">http://thecodebarbarian.com/getting-started-with-azure-functions-and-mongodb.html</a>  </p>
  
  <p>Has anyone used this in production or understand if this is the correct approach?     </p>