Azure Functions connect to on-premises SQL Server

2019-07-09 06:48发布

问题:

I am trying to connect my new Azure Function to an on-premises SQL Server database. The Microsoft docs mention that this is possible, but I have not been able to figure it out nor have I seen any tutorials about specifically setting up a on-premises db with Azure Functions.

I want to do something similar to this tutorial.

public static async void Run(TimerInfo myTimer, TraceWriter log)
{
    var str = ConfigurationManager.ConnectionStrings["on-prem-connection"].ConnectionString;

    //open connections and call db here - I know this
}

Can I do it in a similar way to the video above where I set up a connection string and then reference that connections string in the Azure Function. If so how is that done.

Thanks you.

回答1:

You would need to use something like Hybrid Connection. Check out the following link. I hope it helps: https://azure.microsoft.com/en-us/documentation/articles/web-sites-hybrid-connection-connect-on-premises-sql-server/



回答2:

Possible but using Azure function as deployed under App Service Plan.

Go to "Platform Features" and select "Networking" - there you will get the option to setup the Hybrid connection for the Azure Function.