Forum Discussion
NetFramework dll called from Azure Fn + DbConnection
Hi! Two questions:
1) Is there any caveat/concern about calling .net 4.61 code from AzFn 3 ? we are porting our app from webapi to AzFn, but not ready to migrate all to netcore.
2) Currently each function opens and closes the SqlConnection to Azure Sql as soon as possible. Is there a better practice on AzFns?
2 Replies
- Ryan BerryCopper Contributor
dfirka1970 Yes this is possible using a shared project as one path (https://stackoverflow.com/questions/37608032/net-core-classlibrary-calling-net-framework-class-library) One thing to note is that since .NET FX is not cross-platform you'll be limited to where you can run this .NET core application. Also the 1.x version of Azure functions can run .NET Framework code natively: https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions#languages
There are some best practices posted here on SQL Connections in Azure functions: https://stackoverflow.com/questions/41208524/sql-connection-pooling-in-azure-functions#:~:text=Azure%20Functions%20doesn%27t%20currently%20have%20SQL%20as%20an,pooling%20%29%2C%20you%20should%20get%20pooling%20by%20default.
- Nills Franssens
Microsoft
1. You should test calling .net 4.61 code on functions v3. Since the runtime is .net core, there's no guarantee that .net 4.61 code will run without any issues. If you need full .net framework you could try running on a runtime v1.
2. Best practice is to reuse connections if possible. Check out this documentation page for more info: https://docs.microsoft.com/en-us/azure/azure-functions/manage-connections