1

我有一个 .Net Core 3.0 API 和一个 sql server 2019 数据库,在我开发的机器上运行。我有 2 个 API 测试需要连接到数据库,传入 Visual Studio 测试资源管理器

但是在 azure devops 上,我的管道构建在这 2 个 API 测试中失败了我为共享内存设置了 sqlserver,命名管道和 tcp/ip 没有更改端口 1433 在 sql server 中启用了远程连接进行了登录和数据库登录模式连接了我的 ssms通过 sql server 身份验证已使用数据库上的 vs2019 sql server 对象资源管理器属性选项卡来获取与 sql server 身份验证连接的 db 的连接字符串已停止并定期重新启动所有 sql 服务。我的windows防火墙也断开了))

yml 中失败的构建任务

- task: DotNetCoreCLI@2
  displayName: 'Running Tests'
  inputs:
    command: test
    projects: '**/*Tests.csproj'
    arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'

得到以下错误:

Microsoft.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: Named Pipes Provider, error: 40
        - Could not open a connection to SQL Server)
        ---- System.ComponentModel.Win32Exception : The network path was not found.

连接字符串:

"Data Source=LAPTOP-SOMERANDOM-NAME;Initial Catalog=DBName;User ID=Admin;Password=*****;
Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

如果我在数据源之后添加端口“1433”,我会收到以下错误:

Microsoft.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 - No such host is known.)
---- System.ComponentModel.Win32Exception : No such host is known.

我可以让它工作吗?我是否需要在管道中克隆某种类型的数据库?

不幸的是,我没有信用卡,也没有 azure 资源组的免费积分,我也不使用 keyvault,我正在尝试先建立连接,以后会更安全:)

非常感谢您的阅读和帮助!

4

0 回答 0