SqlAzureDacpacDeployment@1 - Azure SQL 資料庫部署 v1 工作

使用此工作來使用 DACPAC 部署 Azure SQL 資料庫,或使用 SQLCMD 執行腳本。

使用此工作來使用 DACPAC 部署 Azure SQL 資料庫,或使用 SQLCMD 執行腳本。

Syntax

# Azure SQL Database deployment v1
# Deploy an Azure SQL Database using DACPAC or run scripts using SQLCMD.
- task: SqlAzureDacpacDeployment@1
  inputs:
    #azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Service Connection Type. Default: ConnectedServiceNameARM.
    #azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription. 
    azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription. 
  # SQL Database
    AuthenticationType: 'server' # 'server' | 'aadAuthenticationPassword' | 'aadAuthenticationIntegrated' | 'connectionString' | 'servicePrincipal'. Required. Authentication Type. Default: server.
    #ServerName: # string. Required when AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal. Azure SQL Server. 
    #DatabaseName: # string. Required when AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal. Database. 
    SqlUsername: # string. Required when AuthenticationType = server. Login. 
    SqlPassword: # string. Required when AuthenticationType = server. Password. 
    #aadSqlUsername: # string. Required when AuthenticationType = aadAuthenticationPassword. Login. 
    #aadSqlPassword: # string. Required when AuthenticationType = aadAuthenticationPassword. Password. 
    #ConnectionString: # string. Required when AuthenticationType = connectionString. Connection String. 
  # Deployment Package
    deployType: 'DacpacTask' # 'DacpacTask' | 'SqlTask' | 'InlineSqlTask'. Alias: TaskNameSelector. Required. Deploy type. Default: DacpacTask.
    DeploymentAction: 'Publish' # 'Publish' | 'Extract' | 'Export' | 'Import' | 'Script' | 'DriftReport' | 'DeployReport'. Required when TaskNameSelector = DacpacTask. Action. Default: Publish.
    #DacpacFile: # string. Required when DeploymentAction = Publish || DeploymentAction = Script || DeploymentAction = DeployReport. DACPAC File. 
    #BacpacFile: # string. Required when DeploymentAction = Import. BACPAC File. 
    #SqlFile: # string. Required when TaskNameSelector = SqlTask. SQL Script. 
    #SqlInline: # string. Required when TaskNameSelector = InlineSqlTask. Inline SQL Script. 
    #PublishProfile: # string. Optional. Use when TaskNameSelector = DacpacTask || DeploymentAction = Script || DeploymentAction = DeployReport. Publish Profile. 
    #AdditionalArguments: # string. Optional. Use when TaskNameSelector = DacpacTask || DeploymentAction = Extract || DeploymentAction = Export || DeploymentAction = Import || DeploymentAction = Script || DeploymentAction = DeployReport || DeploymentAction = DriftReport. Additional SqlPackage.exe Arguments. 
    #SqlAdditionalArguments: # string. Optional. Use when TaskNameSelector = SqlTask. Additional Invoke-Sqlcmd Arguments. 
    #InlineAdditionalArguments: # string. Optional. Use when TaskNameSelector = InlineSqlTask. Additional Invoke-Sqlcmd Arguments. 
  # Firewall
    IpDetectionMethod: 'AutoDetect' # 'AutoDetect' | 'IPAddressRange'. Required. Specify Firewall Rules Using. Default: AutoDetect.
    #StartIpAddress: # string. Required when IpDetectionMethod = IPAddressRange. Start IP Address. 
    #EndIpAddress: # string. Required when IpDetectionMethod = IPAddressRange. End IP Address. 
    #DeleteFirewallRule: true # boolean. Delete Rule After Task Ends. Default: true.
# Azure SQL Database deployment v1
# Deploy an Azure SQL Database using DACPAC or run scripts using SQLCMD.
- task: SqlAzureDacpacDeployment@1
  inputs:
    #azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Service Connection Type. Default: ConnectedServiceNameARM.
    #azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription. 
    azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription. 
  # SQL Database
    AuthenticationType: 'server' # 'server' | 'aadAuthenticationPassword' | 'aadAuthenticationIntegrated' | 'connectionString'. Required. Authentication Type. Default: server.
    #ServerName: # string. Required when AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated. Azure SQL Server. 
    #DatabaseName: # string. Required when AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated. Database. 
    SqlUsername: # string. Required when AuthenticationType = server. Login. 
    SqlPassword: # string. Required when AuthenticationType = server. Password. 
    #aadSqlUsername: # string. Required when AuthenticationType = aadAuthenticationPassword. Login. 
    #aadSqlPassword: # string. Required when AuthenticationType = aadAuthenticationPassword. Password. 
    #ConnectionString: # string. Required when AuthenticationType = connectionString. Connection String. 
  # Deployment Package
    deployType: 'DacpacTask' # 'DacpacTask' | 'SqlTask' | 'InlineSqlTask'. Alias: TaskNameSelector. Required. Deploy type. Default: DacpacTask.
    DeploymentAction: 'Publish' # 'Publish' | 'Extract' | 'Export' | 'Import' | 'Script' | 'DriftReport' | 'DeployReport'. Required when TaskNameSelector = DacpacTask. Action. Default: Publish.
    #DacpacFile: # string. Required when DeploymentAction = Publish || DeploymentAction = Script || DeploymentAction = DeployReport. DACPAC File. 
    #BacpacFile: # string. Required when DeploymentAction = Import. BACPAC File. 
    #SqlFile: # string. Required when TaskNameSelector = SqlTask. SQL Script. 
    #SqlInline: # string. Required when TaskNameSelector = InlineSqlTask. Inline SQL Script. 
    #PublishProfile: # string. Optional. Use when TaskNameSelector = DacpacTask || DeploymentAction = Script || DeploymentAction = DeployReport. Publish Profile. 
    #AdditionalArguments: # string. Optional. Use when TaskNameSelector = DacpacTask || DeploymentAction = Extract || DeploymentAction = Export || DeploymentAction = Import || DeploymentAction = Script || DeploymentAction = DeployReport || DeploymentAction = DriftReport. Additional SqlPackage.exe Arguments. 
    #SqlAdditionalArguments: # string. Optional. Use when TaskNameSelector = SqlTask. Additional Invoke-Sqlcmd Arguments. 
    #InlineAdditionalArguments: # string. Optional. Use when TaskNameSelector = InlineSqlTask. Additional Invoke-Sqlcmd Arguments. 
  # Firewall
    IpDetectionMethod: 'AutoDetect' # 'AutoDetect' | 'IPAddressRange'. Required. Specify Firewall Rules Using. Default: AutoDetect.
    #StartIpAddress: # string. Required when IpDetectionMethod = IPAddressRange. Start IP Address. 
    #EndIpAddress: # string. Required when IpDetectionMethod = IPAddressRange. End IP Address. 
    #DeleteFirewallRule: true # boolean. Delete Rule After Task Ends. Default: true.
# Azure SQL Database Deployment v1
# Deploy Azure SQL DB using DACPAC or run scripts using SQLCMD.
- task: SqlAzureDacpacDeployment@1
  inputs:
    #azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Service Connection Type. Default: ConnectedServiceNameARM.
    #azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription. 
    azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription. 
  # SQL DB Details
    ServerName: # string. Required. Azure SQL Server Name. 
    DatabaseName: # string. Required. Database Name. 
    SqlUsername: # string. Required. Server Admin Login. 
    SqlPassword: # string. Required. Password. 
  # Deployment Package
    DeploymentAction: 'Publish' # 'Publish' | 'Extract' | 'Export' | 'Import' | 'Script' | 'DriftReport' | 'DeployReport'. Required. Action. Default: Publish.
    #TaskNameSelector: 'DacpacTask' # 'DacpacTask' | 'SqlTask' | 'InlineSqlTask'. Optional. Use when DeploymentAction = Publish. Type. Default: DacpacTask.
    #DacpacFile: # string. Required when TaskNameSelector = DacpacTask || DeploymentAction = Script || DeploymentAction = DeployReport. DACPAC File. 
    #BacpacFile: # string. Required when DeploymentAction = Import. BACPAC File. 
    #SqlFile: # string. Required when TaskNameSelector = SqlTask. SQL Script. 
    #SqlInline: # string. Required when TaskNameSelector = InlineSqlTask. Inline SQL Script. 
    #PublishProfile: # string. Optional. Use when TaskNameSelector = DacpacTask || DeploymentAction = Script || DeploymentAction = DeployReport. Publish Profile. 
    #AdditionalArguments: # string. Optional. Use when TaskNameSelector = DacpacTask || DeploymentAction = Extract || DeploymentAction = Export || DeploymentAction = Import || DeploymentAction = Script || DeploymentAction = DeployReport || DeploymentAction = DriftReport. Additional SqlPackage.exe Arguments. 
    #SqlAdditionalArguments: # string. Optional. Use when TaskNameSelector = SqlTask. Additional Invoke-Sqlcmd Arguments. 
    #InlineAdditionalArguments: # string. Optional. Use when TaskNameSelector = InlineSqlTask. Additional Invoke-Sqlcmd Arguments. 
  # Firewall
    IpDetectionMethod: 'AutoDetect' # 'AutoDetect' | 'IPAddressRange'. Required. Specify Firewall Rules Using. Default: AutoDetect.
    #StartIpAddress: # string. Required when IpDetectionMethod = IPAddressRange. Start IP Address. 
    #EndIpAddress: # string. Required when IpDetectionMethod = IPAddressRange. End IP Address. 
    #DeleteFirewallRule: true # boolean. Delete Rule After Task Ends. Default: true.

輸入

azureConnectionType - Azure 服務連線類型
輸入別名: ConnectedServiceNameSelectorstring. 允許的值: ConnectedServiceName (Azure 傳統) , ConnectedServiceNameARM (Azure Resource Manager) 。 預設值:ConnectedServiceNameARM


azureClassicSubscription - Azure 傳統訂用帳戶
輸入別名: ConnectedServiceNamestring. 當 ConnectedServiceNameSelector = ConnectedServiceName 時為必要。

指定部署 SQL 檔案的目標 Azure 傳統訂用帳戶。


azureSubscription - Azure 訂用帳戶
輸入別名: ConnectedServiceNameARMstring. 當 ConnectedServiceNameSelector = ConnectedServiceNameARM 時為必要。

指定部署 SQL 檔案的目標 Azure Resource Manager 訂用帳戶。


AuthenticationType - 驗證類型
string. 必要。 允許的值: server (SQL Server 驗證) 、 aadAuthenticationPassword (Active Directory - 密碼) 、 (Active Directory - 整合式) 、 aadAuthenticationIntegratedconnectionString (連接字符串) 、 servicePrincipal (服務主體) 。 預設值:server

指定資料庫驗證的類型。 它可以是 SQL Server、Active Directory (整合式) 、Active Directory (密碼) 、連接字串 或服務主體驗證。 整合式驗證表示代理程式會使用其目前的 Active Directory 帳戶內容來存取資料庫。

指定連接到 Azure SQL Server 資料庫的選項。 您可以提供 Azure SQL Server 資料庫詳細數據、SQL Server 連接字串、AD 驗證 (密碼或整合式) ,或使用服務主體。 如需 SQL Server 驗證,請使用 SQL Server 的用戶認證。 針對 AD 驗證,請使用設定為 SQL Server 之 AD 使用者的認證。


AuthenticationType - 驗證類型
string. 必要。 允許的值: server (SQL Server 驗證) 、 aadAuthenticationPassword (Active Directory - 密碼) 、 aadAuthenticationIntegrated (Active Directory - 整合式) , connectionString (連接字符串) 。 預設值:server

指定資料庫驗證的類型。 它可以是 SQL Server、Active Directory (整合式) 、Active Directory (密碼) 、連接字串 或服務主體驗證。 整合式驗證表示代理程式會使用其目前的 Active Directory 帳戶內容來存取資料庫。

指定連接到 Azure SQL Server 資料庫的選項。 您可以提供 Azure SQL Server 資料庫詳細數據、SQL Server 連接字串、AD 驗證 (密碼或整合式) ,或使用服務主體。 如需 SQL Server 驗證,請使用 SQL Server 的用戶認證。 針對 AD 驗證,請使用設定為 SQL Server 之 AD 使用者的認證。


ServerName - Azure SQL 伺服器
string. 當 AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal 時為必要。

指定 Azure SQL 伺服器名稱,例如 Fabrikam.database.windows.net,1433Fabrikam.database.windows.net


ServerName - Azure SQL 伺服器
string. 當 AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated 時為必要。

指定 Azure SQL 伺服器名稱,例如 Fabrikam.database.windows.net,1433Fabrikam.database.windows.net


ServerName - Azure SQL 伺服器名稱
string. 必要。

指定 Azure SQL 伺服器名稱,例如 Fabrikam.database.windows.net,1433Fabrikam.database.windows.net


DatabaseName - 資料庫
string. 當 AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal 時為必要。

指定部署檔案 Azure SQL 資料庫的名稱。


DatabaseName - 資料庫
string. 當 AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated 時為必要。

指定部署檔案 Azure SQL 資料庫的名稱。


DatabaseName - 資料庫名稱
string. 必要。

指定部署檔案 Azure SQL 資料庫的名稱。


SqlUsername - 登錄
string. 當 AuthenticationType = server 時為必要。

指定伺服器管理員登入 Azure SQL。


SqlUsername - 伺服器 管理員 登入
string. 必要。

指定 Azure SQL 伺服器管理員登入或 Active Directory 用戶名稱。


SqlPassword - 密碼
string. 當 AuthenticationType = server 時為必要。

指定 Azure SQL 伺服器管理員的密碼。 在組建或發行管線中定義的變數,如 $(passwordVariable) 已接受。 您可以將變數類型標示為 secret 來保護它。


SqlPassword - 密碼
string. 必要。

指定 Azure SQL 伺服器管理員的密碼。 在組建或發行管線中定義的變數,如 $(passwordVariable) 已接受。 您可以將變數類型標示為 secret 來保護它。


aadSqlUsername - 登錄
string. 當 AuthenticationType = aadAuthenticationPassword 時為必要。

指定 Active Directory 用戶名稱。


aadSqlPassword - 密碼
string. 當 AuthenticationType = aadAuthenticationPassword 時為必要。

指定 Active Directory 用戶的密碼。 在組建或發行管線中定義的變數,如 $(passwordVariable) 已接受。 您可以將變數類型標示為 secret 來保護它。


ConnectionString - 連接字串
string. 當 AuthenticationType = connectionString 時為必要。

指定 Azure SQL Server 連接字串,例如 Server=testServer.database.windows.net;Database=testdb;User ID=AccountPlaceholder;Password=$(securePassword);


deployType - 部署類型
輸入別名: TaskNameSelectorstring. 必要。 允許的值: DacpacTask (SQL DACPAC 檔案) 、 SqlTask (SQL 腳稿檔案) , InlineSqlTask (內嵌 SQL 腳本) 。 預設值:DacpacTask


DeploymentAction - 行動
string. 當 TaskNameSelector = DacpacTask 時為必要。 允許的值:Publish、、、ExtractExportScriptImportDriftReport (Drift Report) , DeployReport (部署報表) 。 預設值:Publish

指定清單中的其中一個 SQL 動作。 深入瞭解 SQL 動作清單


DeploymentAction - 行動
string. 必要。 允許的值:Publish、、、ExtractExportScriptImportDriftReport (Drift Report) , DeployReport (部署報表) 。 預設值:Publish

從清單中指定其中一個 SQL 動作。 深入瞭解 SQL 動作清單


DacpacFile - DACPAC 檔案
string. 當 DeploymentAction = Publish || DeploymentAction = Script || DeploymentAction = DeployReport 時為必要。

指定自動化代理程式上 DACPAC 檔案的位置,或自動化代理程式可存取的 UNC 路徑, 例如 \\BudgetIT\Web\Deploy\FabrikamDB.dacpac。 您也可以使用預先定義的系統變數,例如 $(agent.releaseDirectory)


DacpacFile - DACPAC 檔案
string. 當 TaskNameSelector = DacpacTask || DeploymentAction = Script || DeploymentAction = DeployReport 時為必要。

指定自動化代理程式上 DACPAC 檔案的位置,或自動化代理程式可存取的 UNC 路徑, 例如 \\BudgetIT\Web\Deploy\FabrikamDB.dacpac。 您也可以使用預先定義的系統變數,例如 $(agent.releaseDirectory)


BacpacFile - BACPAC 檔案
string. 當 DeploymentAction = Import 時為必要。

指定自動化代理程式上 BACPAC 檔案的位置,或在自動化代理程式可存取的 UNC 路徑上,例如 \\BudgetIT\Web\Deploy\FabrikamDB.bacpac。 您也可以使用預先定義的系統變數,例如 $(agent.releaseDirectory)


SqlFile - SQL 腳本
string. 當 TaskNameSelector = SqlTask 時為必要。

指定自動化代理程式上 SQL 文稿檔案的位置,或自動化代理程式可存取的 UNC 路徑,例如 \\BudgetIT\Web\Deploy\FabrikamDB.sql。 您也可以使用預先定義的系統變數,例如 $(agent.releaseDirectory)


SqlInline - 內嵌 SQL 腳稿
string. 當 TaskNameSelector = InlineSqlTask 時為必要。

指定要在先前選取的資料庫上執行的 SQL 腳稿。


PublishProfile - 發佈配置檔
string. 選擇性。 使用 時 TaskNameSelector = DacpacTask || DeploymentAction = Script || DeploymentAction = DeployReport

提供 Azure SQL 資料庫建立或升級的精細控制。
指定自動化代理程式機器或 UNC 共用上發佈設定檔 XML 檔案的路徑。 如果發行配置檔包含密碼,例如認證,請將它上傳至 安全檔案 庫,其中會使用加密安全地儲存。 接下來,使用管線開頭的 [下載安全檔案 ] 工作,在管線執行時將其下載到代理程序計算機。 當管線完成時,請將其刪除。 您也可以使用預先定義的系統變數,例如 $(agent.buildDirectory)$(agent.releaseDirectory)


AdditionalArguments - 其他 SqlPackage.exe 自變數
string. 選擇性。 使用 時 TaskNameSelector = DacpacTask || DeploymentAction = Extract || DeploymentAction = Export || DeploymentAction = Import || DeploymentAction = Script || DeploymentAction = DeployReport || DeploymentAction = DriftReport

指定在選取 DACPAC 選項時,部署 Azure SQL 資料庫時套用的其他SqlPackage.exe自變數,例如 /p:IgnoreAnsiNulls=True /p:IgnoreComments=True。 如果提供) ,這些自變數將會覆寫發行配置檔 XML 檔案中的設定 (。


SqlAdditionalArguments - 其他 Invoke-Sqlcmd 自變數
string. 選擇性。 使用 時 TaskNameSelector = SqlTask

指定在 Azure SQL 資料庫上執行指定 SQL 查詢時所套用的其他 Invoke-Sqlcmd 自變數,例如 -ConnectionTimeout 100 -OutputSqlErrors


InlineAdditionalArguments - 其他 Invoke-Sqlcmd 自變數
string. 選擇性。 使用 時 TaskNameSelector = InlineSqlTask

指定在 Azure SQL Database 上執行指定 SQL 查詢時所套用的其他 Invoke-Sqlcmd 自變數,例如 -ConnectionTimeout 100 -OutputSqlErrors


IpDetectionMethod - 使用 指定防火牆規則
string. 必要。 允許值:AutoDetectIPAddressRange。 預設值:AutoDetect

若要讓工作執行,自動化代理程式的IP位址必須新增至 Azure SQL 伺服器防火牆中的[允許的IP位址]。 選取 [自動偵測] 以自動新增自動化代理程式可能IP位址範圍的防火牆例外狀況,或明確指定範圍。


StartIpAddress - 啟動IP位址
string. 當 IpDetectionMethod = IPAddressRange 時為必要。

指定自動化代理程式電腦集區的起始IP位址,例如 196.21.30.50


EndIpAddress - 結束IP位址
string. 當 IpDetectionMethod = IPAddressRange 時為必要。

指定自動化代理程式機器集區的結束 IP 位址, 例如 196.21.30.65


DeleteFirewallRule - 工作結束之後刪除規則
boolean. 預設值:true

如果選取,在工作結束時,此處指定的IP位址會從Azure SQL 伺服器的防火牆中的 [允許的IP位址] 清單中刪除。


TaskNameSelector - 類型
string. 選擇性。 使用 時 DeploymentAction = Publish。 允許的值: DacpacTask (SQL DACPAC 檔案) 、 SqlTask (SQL 腳本檔案) 、 InlineSqlTask (內嵌 SQL 腳本) 。 預設值:DacpacTask


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制選項和一般工作屬性

輸出變數

此工作會定義下列 輸出變數,您可以在下游步驟、作業和階段中使用。

SqlDeploymentOutputFile
當部署套件動作為ExtractExport、、 ScriptDriftReportDeployReport時,產生的輸出檔案路徑。

備註

使用此工作可以使用 DACPAC 部署 Azure SQL 資料庫,或使用 SQLCMD 執行腳本。

重要

只有在 Windows 環境中才支援這項工作。 如果您嘗試使用 Azure Active Directory (Azure AD) 整合式驗證,則必須建立私人代理程式。 裝載的代理程式不支援 Azure AD 整合式驗證。

規格需求

需求 描述
管線類型 YAML、傳統組建、傳統版本
在上執行 代理程式
要求 自我裝載代理程式必須具備符合下列需求的功能,才能執行使用此工作的作業:sqlpackage
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 1.103.0 或更新版本
工作類別 部署