如何通过 VPN 将 Azure 函数(而非应用服务)连接到本地 SQL 服务器?

How do you connect an Azure Function (not an App Service) to an on-premise SQL server via a VPN?

我有一个大型 SQL 服务器托管在我们的基础架构中,并且 Azure 资源设置为可以通过 VPN 访问我们的服务器。

我想创建一个连接到此 SQL 服务器的 Azure 函数。它将成为一个保存到该数据库的 webhook 端点。我不需要应用服务计划的开销,我想要轻量级的功能和更便宜的消费定价模型。

所有在线教程都涉及 Azure Functions on Consumption Plans 中似乎不可用的应用服务和混合连接。

我还想在 Azure 中保留连接字符串配置,而不是在源代码或发布中进行硬编码(最终将通过 CI)。

Azure Function 目前在 VS2019 中使用 C# 编码,但如果有帮助,我可以更改它。

我该如何设置?

是的,这是可能的。您需要使用类似 Hybrid Connection 的东西。无论您使用哪个 IDE 创建 function.Check 以下 link.

The Hybrid Connections feature requires a relay agent in the network that hosts your Hybrid Connection endpoint. That relay agent is called the Hybrid Connection Manager (HCM). To download HCM, from your app in the Azure portal, select Networking > Configure your Hybrid Connection endpoints.

Azure App Service Hybrid Connections

此选项在消费计划中不可用。已经有一个用户为此打开了声音。

https://feedback.azure.com/forums/355860-azure-functions/suggestions/33398398-add-support-for-hybrid-connections-to-consumption