Azure CI (YAML) 管道在任务 SqlAzureDacpacDeployment@1 上失败,SqlPackage.exe 退出,代码为 1
我有一个数据库项目正在部署到Azure SQL数据库实例。该CI管道正在组织以外的另一个环境中工作。我们将其提升/将其转移到该组织。失败的工作是部署工作。所使用的任务是sqlazuredacpacdeployment@1
。
错误消息:
## [错误] ***发生了意外的失败:发生一个或多个错误。
## [错误] Azure SQL DACPAC任务失败了。 sqlpackage.exe用代码退出1.检查如何解决如何解决故障
”
- task: SqlAzureDacpacDeployment@1
displayName: 'info...'
inputs:
azureSubscription: $(ServiceConnection)
serverName: $(sqlServer)
databaseName: $(DbName)
SqlUsername: $(AdminAccount)
SqlPassword: $(AdminAccountPassword)
dacpacFile: '$(BuildName)\\db_name\\bin\\Output\\db_name.dacpac'
publishProfile: '$(BuildName)$(publishProfile)'
部署任务是使用DACPAC和发布配置文件的组合。由于广泛使用SQLCMD变量,这是必要的。代理是一个自托管的Windows代理。它已更新。每次添加用户定义的功能时,代理服务都重新启动。
- 我已经通过两个帐户连接到目标实例来验证了帐户和密码。
- 我尝试使用Azure Active Directory主体对Azure SQL数据库上的管理员进行身份验证。
- 我尝试使用SQL Server身份验证。
- 我已经将用户定义的功能添加到Windows自托管代理的SQLPackage,其兼容性级别150与数据库兼容性级别相匹配。
- 我尝试将数据库兼容性级别从150降低到130,以匹配系统在代理商上定义功能。
- 我验证了目录结构与YAML匹配,并且存在DACPAC和发布配置文件。
- 我验证了存储在YAML外部管道变量中的值。
- 我验证了运行代理的机器在Azure SQL数据库实例上启用了防火墙规则。
我现在正在寻找一项同样的任务。
I have a database project that is being deployed to an Azure SQL Database instance. This CI pipe was working in another environment outside the organization. We lift/shifted it into this organization. The job that is failing is a deployment job. The task that is used is SqlAzureDacpacDeployment@1
.
Error message:
##[error]*** An unexpected failure occurred: One or more errors occurred..
##[error]The Azure SQL DACPAC task failed. SqlPackage.exe exited with code 1.Check out how to troubleshoot failures at
https://aka.ms/sqlazuredeployreadme#troubleshooting-
Code:
- task: SqlAzureDacpacDeployment@1
displayName: 'info...'
inputs:
azureSubscription: $(ServiceConnection)
serverName: $(sqlServer)
databaseName: $(DbName)
SqlUsername: $(AdminAccount)
SqlPassword: $(AdminAccountPassword)
dacpacFile: '$(BuildName)\\db_name\\bin\\Output\\db_name.dacpac'
publishProfile: '$(BuildName)$(publishProfile)'
The deployment task is using a combination of DACPAC and a publish profile. This is necessary due to extensive usage of SQLCMD variables. The agent is a self-hosted Windows agent. It has been updated. Each time a user defined capability was added the agent service was restarted.
- I have validated the account and password by connecting to the target instance with both accounts.
- I have tried authenticating with Azure Active Directory principals which are admins on the Azure SQL Database.
- I tried using SQL Server authentication.
- I have added a user defined capability to the Windows Self-hosted agent for SqlPackage with compatibility level 150 which matched the database compatibility level.
- I tried reducing the database compatibility level from 150 to 130 to match the system define capability on the agent.
- I verified that the directories structure matches the YAML and that the DACPAC and the publish profile exist.
- I verified the values stored in pipe variables outside of the YAML.
- I verified that the machine that runs the agent has a firewall rule enabled on the Azure SQL Database instance.
I am looking for a likewise task now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用服务主而不是SQL身份验证来部署Azure SQL数据库。
请参阅: https://datasharkx.wordpress.com/2021/03/11/automated-deployment-deployment-ozure-squre-sql-database-azure-azure-sql-data -warehouse-through-azure-devops-via-service-principal-part-part-part-1/
https://datasharkx.wordpress.com/2021/ 03/12/自动启动启动 - 武器 - sql-database-azure-sql-data-warehouse-trough-azure-devops-via-service-service-service-principal-part-part-part-2/
另外,删除
PublishProfile < /code>选项,而是以这种格式提供了项目变量:
frosearguments: /v:myVariable = y /v:emovention = tst < /code>,
这应该有效。
您的最终yaml文件应该看起来像这样:
You can use Service Principal instead of SQL Authentication to deploy the Azure SQL Database.
Refer: https://datasharkx.wordpress.com/2021/03/11/automated-deployment-of-azure-sql-database-azure-sql-data-warehouse-through-azure-devops-via-service-principal-part-1/
https://datasharkx.wordpress.com/2021/03/12/automated-deployment-of-azure-sql-database-azure-sql-data-warehouse-through-azure-devops-via-service-principal-part-2/
Also, remove the
publishProfile
option and instead provided project variables in this format:AdditionalArguments: /v:MyVariable=Y /v:Environment=TST
,and this should work.
Your final YAML file should look like this: