简体   繁体   中英

Why my visual studio 2015 SQL Server doesn't connect with Azure SQL Database?

I have a SQL Server running on Microsoft Azure. I want to connect it to My Project in Visual Studio 2015 Community. I have added my IP address in firewall on server. I have also made my port 1433 open for sql. But when I try to connect to database this error shows up. Error Message in SQL Server

It appears that this is a two step process and you either missed the VM configuration or the Azure configuration. Based on what you said I believe it is the Azure configuration that may have been missed. This blog post appears to highlight the necessary things that need to be done to connect.

https://blogs.msdn.microsoft.com/ggaurav/2014/01/08/connect-to-sql-database-on-azure-iaas-from-ssms/

Below is an excerpt:

The two settings which you have to make sure you are checking are :

  1. Endpoint is configured for the port on which SQL server is listening ( generally 1433) on the VM machine.

  2. Ports are opened on the VM machine. Even though as per the documentation Cloud adaptor takes care of opening the firewall ports, it doesn't work for the normal connections which you are trying to make. Just type in ” wf.msc” and create a rule for both outgoing and incoming for TCP port 1433.

As soon as you are done with these two, you would be able to connect to the SQL server on the VM machine.

According to your description, I guess your SQL database is a Azure service, not install SQL on Azure VM.
If I understand it correctly, we should check SQL database firewall settings and confirm the name of your database .

The error code means, this error could occur because either the firewall on the server has refused the connection or the server is not configured to accept remote connections.

We can via Azure Portal to check the firewall settings:
Make sure the Allow access to Azure Services is ON , And make sure your client IP address have added to the Client IP address list. 在此处输入图片说明

Also we should confirm the name of your database, make sure we are connect to the right SQL database.

I have also made my port 1433 open for sql. But when I try to connect to database this error shows up.

You also need to enable 1433 port in Network Security Group which related to your VM. Steps below are for your reference.

  1. Find the Network Security Group name which related to your VM in Netowrk interfaces panel.

在此处输入图片说明

  1. Open this NSG, click [Add] button in the Inbound security rules panel

在此处输入图片说明

  1. Add a rule as following.

在此处输入图片说明

  1. After that, we could access the database hosted in VM using following server name format.

Server name format.

[IP address/dns name],1433

For example,

13.81.50.123,1433

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM