简体   繁体   中英

Application cannot connect to local sql DB on azure vm

I have migrated a database and application from a Win 2012 r2 server running on azure VM to a 2016 server running on azure VM. The authentication is stored in an sql 2012 database server running locally which is also running SSRS.

The .net core 1.1 application cannot see the database on the new 2016 server when attempting to connect to it via this connection: "AuthenticationConnection": "Server=xxxxxx.australiasoutheast.cloudapp.azure.com,1433; Database=xxxxxx; User Id=xxxxxx; Password=xxxxxxx;" - and is reporting the error:

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. If you are connecting to a SQL Azure database consider using SqlAzureExecutionStrategy. ---> System.Data.SqlClient.SqlException: 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. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) --->

This connection does work locally on the old 2012 server. On attempting to connect locally on the new server through SSMS using the dns name the database reports the error:

A network related or instance specific error occurred while establishing a connection to SQL server. The server was not found or was not accessible.

I can however access it via SSMS NOT using the dns name, but using the local server name.

I can access the sql database from outside the machine just fine. And when running the app in debug from outside the server it connects fine also. It is only when attempting to access the DB from inside the VM using the dns name.

All ports are open and have tried turning off firewall with no effect. I have ensured mixed mode auth is on the sql database. I have installed all available updates. The only difference in setup between the old server and the new is:

  • The new server is inside an azure virtual net
  • The new server has a static IP (which forced it into a virtual net)
  • The new server is windows 2016

I'm thinking its got something to do with DNS referencing of a local database virtual net is causing some issue but I don't know enough about virtual networking to know what to try. If anyone's got any ideas, please let me know - thanks.

I have changed the connection string in the app to use the local server name as opposed to the dns name and this allowed it to communicate. as to why the FQDN did not work, I don't know. It did in windows server 2012. There's something in the environment that's different but I can't locate it.

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