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.
- Troubleshoot the database firewall
- 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.