简体   繁体   English

应用程序无法连接到Azure VM上的本地SQL DB

[英]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. 我已将数据库和应用程序从运行在azure VM上的Win 2012 r2服务器迁移到了运行在azure VM上的2016服务器。 The authentication is stored in an sql 2012 database server running locally which is also running SSRS. 身份验证存储在同时运行SSRS的本地运行的sql 2012数据库服务器中。

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;" 尝试通过此连接进行连接时,.net core 1.1应用程序无法在新的2016服务器上看到数据库:“ AuthenticationConnection”:“ Server = xxxxxx.australiasoutheast.cloudapp.azure.com,1433; Database = xxxxxx;用户ID = xxxxxx;密码= xxxxxxx;“ - and is reporting the error: -并报告错误:

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. System.InvalidOperationException:引发了一个异常,该异常很可能是由于瞬时故障引起的。 If you are connecting to a SQL Azure database consider using SqlAzureExecutionStrategy. 如果要连接到SQL Azure数据库,请考虑使用SqlAzureExecutionStrategy。 ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. ---> System.Data.SqlClient.SqlException:建立与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配置为允许远程连接。 (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.) ---> (提供者:TCP提供程序,错误:0-连接尝试失败,因为一段时间后连接方未正确响应,或者连接建立因连接主机未能响应而失败。)--->

This connection does work locally on the old 2012 server. 此连接在旧的2012服务器上确实可以在本地工作。 On attempting to connect locally on the new server through SSMS using the dns name the database reports the error: 尝试使用dns名称通过SSMS在新服务器上本地连接时,数据库将报告错误:

A network related or instance specific error occurred while establishing a connection to SQL server. 建立与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. 但是,我可以通过SSMS访问它,而不使用dns名称,而是使用本地服务器名称。

I can access the sql database from outside the machine just fine. 我可以从机器外部访问sql数据库。 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. 仅在尝试使用dns名称从VM内部访问数据库时。

All ports are open and have tried turning off firewall with no effect. 所有端口均已打开,并且尝试关闭防火墙无效。 I have ensured mixed mode auth is on the sql database. 我确保混合模式auth位于sql数据库上。 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) 新服务器具有静态IP(将其强制为虚拟网络)
  • The new server is windows 2016 新服务器是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. 我认为它与本地数据库虚拟网络的DNS引用有关,这引起了一些问题,但是我对虚拟网络了解得不够多,无法知道该怎么做。 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. 我在应用程序中更改了连接字符串,以使用本地服务器名称而不是dns名称,这允许它进行通信。 as to why the FQDN did not work, I don't know. 关于FQDN为什么不起作用的原因,我不知道。 It did in windows server 2012. There's something in the environment that's different but I can't locate it. 它是在Windows Server 2012中完成的。环境中有些不同,但是我找不到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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