需要将Azure App Web服务连接到本地SQL数据库
我有一个部署到Azure应用程序服务的Web Service应用程序,我想将其连接到开发计算机上运行的本地SQL数据库。我已经在同一资源组和设置SQL Server -Web Service应用程序中建立了VPN网关。连接VPN客户端将获得以下IP地址为172.16.254.2。用此IP地址或IP地址替换本地服务器名称:连接字符串中的1433不起作用...我获得Web Server应用程序错误HTTP错误500。我的问题:
- 是否需要其他需要配置防火墙规则来建立连接?
- 有没有一种方法可以测试Azure的本地SQL Server DB连接?
- 我应该实现混合连接器吗?如果是这样,那会消除对VPN网关和本地VPN客户端的需求吗?
I have a Web Service App deployed to an Azure App Service that I would like to connect to an on-premise SQL Database running on my dev computer working from home. I've established a VPN Gateway on the same Resource Group and setup SQL Server - Service Account User for the Web Service App to to connect with. Connecting the VPN Client obtains the following IP Address of 172.16.254.2. Replacing the local server name with this IP Address or IP Address:1433 in the connection string is not working... I get Web Server App error HTTP Error 500. My questions:
- Is something else required like configuring a Firewall Rule to make the connection?
- Is there a way to test an on-prem SQL Server DB Connection from Azure?
- Should I implement a Hybrid Connector? If so would that eliminate the need for the VPN Gateway and local VPN Client?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
肯定有多种配置的方法,但是我能够使它起作用...我会通过回答我的原始问题来解释:
#1& 3:我设置了不需要VPN网关的混合连接...它是网关。如果连接到像我这样的一台计算机,则可以使用计算机名称与IP地址。注意,我在混合连接中列出了端口1433(SQL Server的默认端口),因此不需要将其包括在SQL Connection String中。混合连接需要Azure配置,在应用程序服务中,并在本地计算机上安装混合连接管理器。
当我部署Web Service应用程序时,Azure App Service识别了在AppSetting.json文件中保存的连接字符串,但并未导入所有字符串参数。在Azure应用程序/配置中,我通过将类型从“ Azure SQL”切换到“ SQL Server”,并添加了“ Encrypt = false”来编辑连接字符串。
回答#2:我能够通过在应用程序服务控制台中运行“ TCPPPPING”来测试网络连接,但这仅确认网络连接而不是数据库连接。我需要弄清楚我需要在连接字符串中添加“ Encrypt = false”。我假设它是我的设置独有的...我正在运行SQL 2019。在浏览器中直接运行该服务刚刚返回了500个错误,因此我仍然对如何最好地测试本地DB进行建议与Azure的连接。希望在Azure App Service Dev团队的路线图上有一个“测试连接”选项。
希望这会有所帮助。
There is certainly more than one way to configure this but I was able to get it to work... I'll explain by responding to my original questions:
Answers to #1 & 3: I setup a Hybrid Connection which does Not require a VPN Gateway... it is the Gateway. If connecting to a single machine like myself, the computer name can be used vs. an IP Address. Note, I listed Port 1433 (SQL Server's default port) in the Hybrid Connection and hence did not need to include it in the SQL Connection String. The Hybrid Connection requires both Azure Configuration, within the App Service, and installing a Hybrid Connection Manager on the on-prem machine.
When I deployed the Web Service App the Azure App Service recognized the connection string saved in the appsetting.json file but did Not import all string parameters. In the Azure App Service/Configuration I edited the connection string by switching the Type from "Azure SQL" to "SQL Server" and added "Encrypt=False".
Answer to #2: I was able to test the network connection by running "tcpping" in the App Service Console but this only confirms the network connection and not the database connection. It took some trial and error to figure out I needed to add "Encrypt=False" to the connection string. I'm assuming it's unique to my setup... I'm running SQL 2019. Prior, running the service directly in Browser just returned a 500 Error so I'm still open to suggestions on how best to test an on-prem DB Connection from Azure. Hopefully a "Test Connection" option is on the Azure App Service Dev Team's Roadmap.
Hope this helps.