3
votes

We have an Azure Virtual Machine with SQL Server 2017 Express. However, I can't connect to the SQL Server from my local computer using SSMS.

When trying to connect SSMS throws the error message:
"Cannot connect to (VM name):(port number)
-> A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections."

SQL Server 2017 Express has been natively installed on the VM using the download from https://www.microsoft.com/en-us/sql-server/sql-server-editions-express.
SQL Server 2017 Express has NOT been set up using the setup using the Azure portal like in the example in the following link: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/quickstart-sql-vm-create-portal

I have tried the following guides among others, without luck
- https://logicalread.com/connect-windows-azure-vm-using-ssms-tl01/#.XF1dIjNKiUl
- https://www.youtube.com/watch?v=5UkHYNwUtCo
- https://blogs.msdn.microsoft.com/sqlexpress/2005/05/05/how-to-configure-express-to-accept-remote-connections/
- https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/virtual-machines-windows-sql-connect
- https://social.technet.microsoft.com/wiki/contents/articles/36674.access-azure-vm-sql-server-outside-of-network.aspx

I have done the following
- Windows Firewall with Advanced Security
--> Adding firewall inbound rule opening the port 1433 & 49170
- SQL Server Configuration Manager
-> SQL Server Network Configuration
--> Protocols for SQLEXPRESS
---> TCP/IP, set to "Enabled"
----> TCP/IP Properties, IP Addresses, IPAll, "TCP Port" set to 49170
----> TCP/IP Properties, IP Addresses, IPAll, "TCP Dynamic Ports" made blank
-> SQL Server Services
--> SQL Server (SQLEXPRESS), restart service

However, In SSMS my local computer can't connect to the SQL Server on the Azure Virtual Machine.

I have tried starting the SQL Browser Service in SQL Server Configuration Manager, as suggested in Cannot connect to Azure VM with SSMS

I am using Microsoft SQL Server Management Studio 2016 on my local computer.

Why can't I login to the Azure VM's SQL Server from my local computer using SSMS?
Is there something blocking the connection from SSMS?

I have also tried to ping the VM from my local computer using command prompt but without success. I can't ping my VM even if I temporarily disabled the Windows firewall on it. On the following article it says that the Azure load balancer could be blocking the signal https://www.petri.com/how-to-remotely-ping-microsoft-azure-vms
Could this be the same issue which blocks Access to the Virtual Machine's SQL Server from my local computer's SSMS?

2

2 Answers

3
votes

I have been having the same problem and here is what worked for me. Check to make sure the Port value in configuration is not empty. When I added it, I was able to connect. See attached screen shot.

enter image description here

0
votes

You mention that you have opened things up in Windows Firewall, but have you opened any ports in the Azure Network Security Group? By default when you create a VM Azure will create an NSG, you will need to go to the portal and add an NSG rule to allow port 1433.

Also, note that you will be unable to ping an Azure VM from the outside, ICMP is disabled.