App Service cannot connect to Azure SQL Database despite firewall and VNet rules

Adel M 0 Reputation points
2025-10-01T07:49:23.57+00:00

We have an Azure App Service that is unable to connect to an Azure SQL Database. The following configuration steps have already been completed, but the issue persists:

All App Service outbound IPs are added to the SQL Server Firewall and Virtual Networks rules.

“Allow Azure services and resources to access this server” is enabled.

Virtual networks are configured and integrated with the App Service.

The connection string in the App Service is correct and follows Azure SQL guidelines.

Despite these configurations, the App Service still fails to connect to the SQL Database.

Request: Could you please help identify why the App Service cannot establish a connection and confirm if there are any additional requirements (DNS, private endpoint configuration, NSG/UDR rules, or service endpoint settings) that may be preventing connectivity?

Please also advise how we can best verify which IP/DNS path the App Service is using when attempting to connect to the SQL server.

Azure Web Application Firewall
{count} votes

2 answers

Sort by: Most helpful
  1. Harish Peddapally 1,330 Reputation points Microsoft External Staff Moderator
    2025-10-01T09:37:54.39+00:00

    Hi Adel M,

    Welcome to Microsoft Q&A and thank you for posting your query here!

    The issue where an Azure App Service cannot connect to an Azure SQL Database despite having the SQL Server firewall and Virtual Network rules configured often relates to additional network and DNS configurations beyond just IP whitelisting.

    Here are key points and steps to verify and resolve this:

    Private Endpoint and DNS Resolution If your Azure SQL Database is configured with a private endpoint, the App Service must resolve the SQL server's fully qualified domain name (FQDN) to the private IP address of that endpoint, not the public IP. This requires proper configuration of Azure Private DNS zones (privatelink.database.windows.net) and ensuring the App Service's VNet integration supports DNS resolution to that private zone. Without correct DNS setup, the App Service will attempt to connect via the public IP and may fail.

    Network Security Groups (NSGs) and User-Defined Routes (UDRs) Verify that NSGs and any UDRs on your subnet(s) or on the VNet gateway allow outbound traffic from the App Service to the SQL Database on port 1433. Incorrect NSG or route rules can block this traffic even if firewall rules seem correct.

    Service Endpoints and VNet Rules IP firewall rules allowing all App Service outbound IPs only work if the SQL Server network access settings include public network access. If VNet service endpoints or private endpoints are configured, IP firewall rules might be bypassed. Service endpoints require the subnet to have the SQL service endpoint enabled and added to the SQL Server’s VNet rules.

    Verification of IP and DNS used by App Service Use the Kudu Console available at https://<your-app-service-name>.scm.azurewebsites.net/DebugConsole to run commands like nslookup <sql-server-name> to check if DNS resolves to expected private or public IP. Also, application logs and Azure SQL diagnostic logging can help confirm connection attempts and source IP.

    Recommended next steps:

    Double-check if Private Endpoint is configured for your SQL Database and ensure the App Service’s DNS can resolve to it correctly.

    • Review NSG rules on the subnet hosting the private endpoint and, on any subnet, used by the App Service VNet integration.

    Confirm port 1433 is allowed outbound from the App Service to the database.

    If using service endpoints, verify they are enabled and properly configured on the VNet subnet.

    Monitor connection attempts using Azure SQL diagnostic logs for further clues.

    For detailed guidance, please refer to Microsoft official documentation below:

    Tutorial on Azure SQL Database Private Endpoint Setup: https://free.blessedness.top/en-us/azure/private-link/tutorial-private-endpoint-sql-portal

    Azure SQL Database Firewall and Virtual Network Configuration: https://free.blessedness.top/en-us/azure/azure-sql/database/firewall-configure?view=azuresql

    This comprehensive approach should help identify why the App Service cannot establish a connection and how to adjust networking, DNS, and security setups accordingly.

    Please do let me know if you have any question on this.

    Thanks,

    Harish.

    0 comments No comments

  2. Adel M 0 Reputation points
    2025-10-01T09:58:07.8166667+00:00

    User's image

    User's image

    User's image

    User's image

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.