0
votes

I deployed a web app on Azure App Services. When web app tries to connect to the Azure SQL Database connection failed.

I downloaded the event log from Kudu, I found the following error message:

Cannot open server 'servername' requested by the login. Client with IP address '**************' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect..

On Azure portal I found how to set server firewall by adding a range of client IP addresses (with lower bound and upper bound) according your client IP address. For instance, if client IP address is 00.000.000.09 the range of IP addresses is: low bound (00.000.000.0) and upper bound (00.000.000.255).

I set the server firewall for the IP address assigned to my Azure App Services account and also for my local machine to connect to Azure SQL Database from SQL Server Management Studio. After setting firewall, I can connect to Azure SQL Database with SQL Server Management Studio. Unfortunately unable to connect from web app. When I download event log from Kudu I find the same message error.

Someone could help to solve that issue.

Thanks.

1
Try setting the firewall to allow Azure Services to access it. Should be a setting in the Database firewall.David Makogon
Could you please check if you have set Allow Azure Services and resources to access this server to ON in SQL server firewall : docs.microsoft.com/en-us/azure/azure-sql/database/…?Jim Xu
Thanks David and Jim for your contribution. I setup server firewall by adding all outbound IP addresses I found in Properties menu of my Azure App Services account. I also allowed Azure Services and resources to access server and I selected Redirect for Connection Policy. Unfortunately unable to access database with my web app hosted on Azure App Services. When I add the IP address of my laptop to server firewall, it's possible to access Azure database by running web app on localhost. It's very crazy, I spent 2 days for trying to solve this issue.user3676871

1 Answers

0
votes
  1. Go to your SQL Server in Azure Portal.
  2. Go to "Firewall and Virtual Network".
  3. Turn on "Allow Azure Service and resources to access this server".

Set to Yes