简体   繁体   English

使用 Azure 发布管道在存储过程中获取“无效的对象名称”

[英]Getting 'Invalid object name' in stored procedure using Azure release pipeline

I'm trying to deploy database changes to a Windows server using an Azure release pipeline.我正在尝试使用 Azure 发布管道将数据库更改部署到 Windows 服务器。 I'm using a DACPAC file with table data included.我正在使用包含表数据的 DACPAC 文件。

This is my code to generate the DACPAC which I run in a build pipeline:这是生成我在构建管道中运行的 DACPAC 的代码:

sqlpackage `
    /Action:Extract `
    /SourceConnectionString:"Data Source=localhost;Initial Catalog=Shipping;Integrated Security=False;Persist Security Info=True;User ID=username;Password=password" `
    /TargetFile:"$PublishDir/Shipping.dacpac" `
    /p:IgnoreUserLoginMappings=True `
    /p:VerifyExtraction=False `
    /p:ExtractAllTableData=True

In the release pipeline I have a deployment group job that contains the following steps:在发布管道中,我有一个部署组作业,其中包含以下步骤:

  1. Disable triggers禁用触发器
  2. Disable constraints禁用约束
  3. Deploy DACPAC部署 DACPAC
  4. Enable triggers启用触发器
  5. Enable constraints启用约束

I use the SQL Server Deployment task for the Deploy DACPAC step.我将 SQL Server 部署任务用于部署 DACPAC 步骤。 Every time it gets to that step this error is thrown:每次到达该步骤时都会引发此错误:

*** Could not deploy package.

Error SQL72014: Framework Microsoft SqlClient Data Provider: Msg 208, Level 16, State 1, Procedure vGetTransportPackages, Line 31 Invalid object name 'FreightDataStore.TP.TransportPackage'.

Error SQL72045: Script execution error.  The executed script:
 CREATE VIEW [fds].[vGetTransportPackages] AS WITH PACKAGES AS (SELECT DISTINCT tp.transportPackageID AS TransportPackageID, tp.tpID AS CarTransportPackageNumber, tp.airWayBillNo AS AirwayBillNumber, tp.pod AS DestinationPort,
(SELECT TOP 1 tl.LocationName FROM fds.TransportLocation AS tl WHERE  tl.UnLocCode = tp.pod) AS DestinationPortName, pod.countryCode AS DestinatonPortCountry, (SELECT TOP 1 c.CountryName FROM   ref.Countries AS c WHERE  c.CountryCode = pod.countryCode) AS DestinationPortCountryName, tp.poe AS OriginPort, (SELECT TOP 1 tl.LocationName FROM   fds.TransportLocation AS tl WHERE  tl.UnLocCode = tp.poe

I'm relatively new to database deployment.我对数据库部署比较陌生。 Do I need to change the way I generate the DACPAC?我是否需要更改生成 DACPAC 的方式?

I figured out the issue.我弄清楚了这个问题。 I didn't install the other databases on the server that my Shipping database depends on.我没有在我的 Shipping 数据库所依赖的服务器上安装其他数据库。 Once I installed FreightDataStore and a few other databases I was able to deploy the DACPAC successfully.一旦我安装了 FreightDataStore 和其他一些数据库,我就能够成功地部署 DACPAC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM