azure-devops - 在管道构建期间获取 sql server (express) azure devops
问题描述
我正在为 asp.net 应用程序设置管道。在集成测试任务期间,我需要连接到 SQL 服务器。我如何对管道说我需要 sql 服务?
我尝试了多个 microsoft 托管代理池(Windows Server 1803、Hosted 2017 和 2019)我使用 Windows Server 1803,问题是:
The operating system of the container does not match the operating system of the host.
我想正确设置一个临时 sql 服务器来运行测试。
我改用了localdb。
我在我的集成测试任务之前运行这个脚本
SqlLocalDB.exe create "DeptLocalDB"
SqlLocalDB.exe share "DeptLocalDB" "DeptSharedLocalDB"
SqlLocalDB.exe start "DeptLocalDB"
SqlLocalDB.exe info "DeptLocalDB"
要与 powershell 连接:Invoke-Sqlcmd -Query "SELECT GETDATE() AS TimeOfQuery;" -ServerInstance "(localdb)\.\DeptSharedLocalDB"
要连接 sqlcmd:sqlcmd -S (localdb)\.\DeptSharedLocalDB
要连接 ac# 应用程序(connectionString):"Data Source=(localdb)\.\DeptS
haredLocalDB;Initial Catalog=DeptLocalDB;Integrated Security=True;"
如果有人知道如何在 azure 管道上的容器中安装 sql 服务器,将不胜感激。感谢阅读
解决方案
Chocolatey 安装在windows-latest
.
因此,如果您在 YAML 文件中定义:
pool:
vmImage: windows-latest
然后,您可以使用 choco 安装 SQL Server Express:
- script: choco install sql-server-express
推荐阅读
- linux - bash 中的复活节计算产生恒定的结果
- mysql - Spring Boot 微服务的 MySQL 配置
- html - 使两个 div 在大屏幕上并排响应,在移动设备上彼此下方
- c# - 如何计算带有变量的按钮的名称
- typescript - 在 TypeScript 中,如果内联函数采用泛型类型的参数,我如何从中“获取”类型参数?
- modelica - 无法求解线性方程组
- c# - 我怎样才能只编码一次并复制 c#
- reactjs - ReactJs - ReferenceError:未定义提取
- java - 作业因阶段失败而中止:阶段 5.0 中的任务 0 失败 1 次,最近一次失败:阶段 5.0 中的任务 0.0 丢失
- excel - 列中唯一值的高级过滤器复制重复值