Azure CI (YAML) 管道在任务 SqlAzureDacpacDeployment@1 上失败,SqlPackage.exe 退出,代码为 1

发布于 2025-01-18 05:04:02 字数 1244 浏览 0 评论 0原文

我有一个数据库项目正在部署到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代理。它已更新。每次添加用户定义的功能时,代理服务都重新启动。

  1. 我已经通过两个帐户连接到目标实例来验证了帐户和密码。
  2. 我尝试使用Azure Active Directory主体对Azure SQL数据库上的管理员进行身份验证。
  3. 我尝试使用SQL Server身份验证。
  4. 我已经将用户定义的功能添加到Windows自托管代理的SQLPackage,其兼容性级别150与数据库兼容性级别相匹配。
  5. 我尝试将数据库兼容性级别从150降低到130,以匹配系统在代理商上定义功能。
  6. 我验证了目录结构与YAML匹配,并且存在DACPAC和发布配置文件。
  7. 我验证了存储在YAML外部管道变量中的值。
  8. 我验证了运行代理的机器在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.

  1. I have validated the account and password by connecting to the target instance with both accounts.
  2. I have tried authenticating with Azure Active Directory principals which are admins on the Azure SQL Database.
  3. I tried using SQL Server authentication.
  4. 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.
  5. I tried reducing the database compatibility level from 150 to 130 to match the system define capability on the agent.
  6. I verified that the directories structure matches the YAML and that the DACPAC and the publish profile exist.
  7. I verified the values stored in pipe variables outside of the YAML.
  8. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么敢 2025-01-25 05:04:02

您可以使用服务主而不是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文件应该看起来像这样:

- task: SqlAzureDacpacDeployment@1
        displayName: Deploy dacpac
        inputs:
          azureSubscription: $(ServiceConnection)
          ServerName: <server_name>
          DatabaseName: <database_name>
          DacpacFile: $(Pipeline.Workspace)\drop\MyDacpac.dacpac
          AdditionalArguments: /v:ResetStuff=Y /v:Environment=TST
          DeploymentAction: Publish
          AuthenticationType: servicePrincipal

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:

- task: SqlAzureDacpacDeployment@1
        displayName: Deploy dacpac
        inputs:
          azureSubscription: $(ServiceConnection)
          ServerName: <server_name>
          DatabaseName: <database_name>
          DacpacFile: $(Pipeline.Workspace)\drop\MyDacpac.dacpac
          AdditionalArguments: /v:ResetStuff=Y /v:Environment=TST
          DeploymentAction: Publish
          AuthenticationType: servicePrincipal
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文