Azure Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server

落爺英雄遲暮 提交于 2019-12-20 01:47:11

问题


I have SQL server & web app hosted over Microsoft Azure platform. I am constantly getting above error when ever i run web application (and try to connect azure sql server) from my local network, however i never face issue on azure web app service (i.e. After hosting my web app on azure)

I know that this error is very familiar. But in this case it seems weird. I have already checked below things,

  1. SQL connection is managed properly. (I am using ADO.Net)
  2. All gateway IPs are white listed against azure sql.
  3. No firewall is blocking my private network.

Any help will be appreciated.


回答1:


From Mihaela's comment: You need to add "tcp: " in front of server name. I.e. tcp:<servername>.database.windows.net


EDIT:

This is specified in the [documentation] (https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx)

Data Source must use the TCP format or the Named Pipes format.

TCP format is as follows:

•tcp:\

•tcp:,

The TCP format must start with the prefix "tcp:" and is followed by the database instance, as specified by a host name and an instance name.

The host name MUST be specified in one of the following ways:

•NetBIOSName

•IPv4Address

•IPv6Address

The instance name is used to resolve to a particular TCP/IP port number on which a database instance is hosted. Alternatively, specifying a TCP/IP port number directly is also allowed. If both instance name and port number are not present, the default database instance is used.



来源:https://stackoverflow.com/questions/38694867/azure-error-a-network-related-or-instance-specific-error-occurred-while-establi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!