我们创建了简单的经典 Azure VM 并拥有 Azure SQL。
我们有一个在虚拟机上运行的应用程序,并尝试在 Azure SQL 上执行一些操作,但是我们无法访问它并出现一般异常
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
我们已经做了一系列事情:
- 在远程数据库服务器中添加虚拟机的公共(public) IP
- 通过 Azure 仪表板添加了 1433 TCP 端点
- 在虚拟机防火墙中添加了 1433 的入站规则
编辑
对于站点到站点 VPN,
- 我们将数据库链接到虚拟机的云服务
- 追踪数据库IP,现在我们可以telnet 1433内的IP了 虚拟机。
但是当我们尝试与数据库交互时,我们仍然在记录器上记录以下错误。
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The target principal name is incorrect.
我们是否遗漏了一些东西
最佳答案
通常,从 Azure VM 连接到 Azure SQL 与从 Azure 外部连接有点不同。
假设您使用最新的 V12 Azure SQL 和最新的 .Net 框架或 SSMS
您需要在 VM 上打开 TCP 端口范围 11000-11999 和 14000-14999 的出站连接 确保您没有任何拦截器(防火墙、使用此端口范围的第三方应用程序)
从 Azure SQL 端,您只需单击防火墙配置边栏选项卡上的“允许 Azure 服务”即可允许从 Azure 内部进行连接
您可以在此处阅读有关连接到 Azure SQL 时使用的端口的更多信息:https://azure.microsoft.com/en-in/documentation/articles/sql-database-develop-direct-route-ports-adonet-v12/
关于 Azure SQL 上的防火墙配置,您可以在此处阅读更多信息:https://azure.microsoft.com/en-in/documentation/articles/sql-database-firewall-configure/#connecting-from-azure
关于c# - 无法使用站点间连接从 Azure VM 连接 Azure SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38450113/