简体   繁体   中英

Azure App Service can't access Azure SQL DB, but local machine works. Allow-All-IP rule already in place.

Currently working on an ASP.NET web application. I would like to deploy to Azure App Service but when running on App Service, the connection to my Azure SQL server can not be found. 在此处输入图片说明

When I run on my local machine, the connection to the Azure SQL server works. I can also connect to my Azure SQL server via SQL Management Studio.

On the Azure SQL server I have set up a Firewall rule to allow all IP addresses, and allowed access to Azure services: 在此处输入图片说明

I have done considerable searching for solutions to this problem over the past couple days, but I can't find a solution.

After spending a few hours tweaking my appsettings.json , Azure firewall settings, permissions, ... it ended up being that I had my App Service > Settings > Configuration > Connection String previously set. And Azure seems to completely ignore your appsettings.json in this case.

蔚蓝截图

I have added the Virtual IP for the Firewall rule and it fixed the issue.

在此处输入图片说明

For more troubleshooting use App insights. Most of the time it shows the exact issue.

You can easy find the app service all outbound ip address on properties

but you need setting all of the outbound ips in your firewall 在此处输入图片说明

I ran into what could be this same problem. Changing the server admin password resolved the issue. I was able to connect running locally, but the published application was unable to log in with the server admin credentials until I reset the server admin password.

在 sql 数据库概述页面上的 azure prortal 上单击设置服务器防火墙允许 Azure 服务和资源访问此服务器应设置为是,其余设置应默认保存更改它适用于我的 asp.net 和 sql db位于 azure env

Works with the solution given by @Tuco. Just an additional setting to remember, as you're mentioning azure sql, don't forget to change the type to SQLAzure.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM