如何解决从 Azure DevOps Pipeline 访问 SQL Server
问题
我已经设置了 Azure Pipeline,但我遇到的问题是,在 Pipeline 的测试程序集部分它失败了,因为它无法解析连接字符串/找到我的 SQL Server。
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: Named Pipes Provider,error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception: The network path was not found
在这种情况下,我想避免创建模拟,理想情况下让代码直接与 SQL Server 通信。
SQL Server 位于 Azure VM 上,因此它不是“Azure SQL 数据库”服务。
我的尝试
我已打开 Azure VM 上的端口,以允许来自 Azure DevOps 使用的所有区域/IP 范围的流量(我在网上发现这是必需的)。我还尝试将管道“测试程序集”内的连接字符串指向另一个(内部部署)Windows 服务器,该服务器包含一个 SQL Server 实例,但它仍然无法找到/连接到 SQL。
从本地(Azure VM 和本地服务器)连接到 SQL 时,我可以连接。我们还有其他一些使用 SQL Server 的服务位于 Azure VM 上,因此我相信连接问题与从 Azure Pipeline 进行连接有关。
以前有人遇到过这个问题吗?
更新
我已经更新了连接字符串以直接引用端口,即
**.***.**.***,1433
并且错误消息现在已更改为:
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 - The wait operation timed out.) ---> System.ComponentModel.Win32Exception: The wait operation timed out
解决方法
我现在可以使用了。
将 Azure DevOps 区域从西欧更改为英国南部后,我的 DevOps 现在可以与我的 VM 上的 SQL Server 通信(根据 Leo Liu-MSFT 的评论,所需的 IP 地址已列入白名单)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。