问题
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,
- SQL connection is managed properly. (I am using ADO.Net)
- All gateway IPs are white listed against azure sql.
- 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