Unable to connect to Azure SQL DB from VM on Azure

Neha 1 Reputation point
2021-03-12T17:23:54.08+00:00

I have created a new Azure SQL Server/DB and trying to connect to the Azure SQL DB from the windows VM that is in Azure, but getting network related error. I've added the VM's client IP in the Azure SQL firewall settings, but no luck. Here is the specific error ![77351-image.png][1] [1]: /api/attachments/77351-image.png?platform=QnA

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 13,951 Reputation points MVP
    2021-03-13T03:27:00.69+00:00

    Hi @Neha

    Thank You for posting in Q & A.

    Generally connecting from Azure VM to Azure SQL is a bit different then connecting from outside of Azure.

    Connections from inside Azure
    To allow applications hosted inside Azure to connect to your SQL server, Azure connections must be enabled. To enable Azure connections, there must be a firewall rule with starting and ending IP addresses set to 0.0.0.0.

    1. Troubleshoot the database firewall
    2. Azure SQL DB Connectivity Troubleshooting
      To check if you can reach the Port 1433, you can use multiple tools like TELNET / PSPING / POWERSHELL

    Find below a simple test using Powershell

    Test-NetConnection -Port 1433 -ComputerName SERVERNAME.database.windows.net  
    

    You now will need to open firewall in the path from Server to Azure SQL DB, like Windows Firewall, Corporate Firewall and/or Azure NSG (Network security group) to allow this communication.

    In this case for Azure VM will open NSG, and you can use Service Tags to simplify this configuration. With Service TAGs you do not need to hard code the SQL Gateway IPs.

    Please don’t forget to Accept the answer and up-vote wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments