SqlAzureDacpacDeployment@1 - Azure SQL Database 部署 v1 工作
使用此工作來使用 DACPAC 部署 Azure SQL Database,或使用 SQLCMD 執行腳本。
語法
# 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.
輸入
azureConnectionType
-
Azure 服務連線類型
輸入別名:ConnectedServiceNameSelector
。
string
。 允許的值:ConnectedServiceName
(Azure 傳統版)、ConnectedServiceNameARM
(Azure Resource Manager)。 預設值:ConnectedServiceNameARM
。
azureClassicSubscription
-
Azure 傳統訂用帳戶
輸入別名:ConnectedServiceName
。
string
。
ConnectedServiceNameSelector = ConnectedServiceName
時為必要項。
指定部署 SQL 檔案的目標 Azure 傳統訂用帳戶。
azureSubscription
-
Azure 訂用帳戶
輸入別名:ConnectedServiceNameARM
。
string
。
ConnectedServiceNameSelector = ConnectedServiceNameARM
時為必要項。
指定部署 SQL 檔案的目標 Azure Resource Manager 訂用帳戶。
AuthenticationType
-
驗證類型
string
。 必須的。 允許的值:server
(SQL Server 驗證)、aadAuthenticationPassword
(Active Directory - 密碼)、aadAuthenticationIntegrated
(Active Directory - 整合式)、connectionString
(連接字符串)、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 Server
string
。
AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal
時為必要項。
指定 Azure SQL Server 名稱,例如 Fabrikam.database.windows.net.placeholder,1433
或 Fabrikam.database.windows.net.placeholder
。
ServerName
-
Azure SQL Server
string
。
AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated
時為必要項。
指定 Azure SQL Server 名稱,例如 Fabrikam.database.windows.net.placeholder,1433
或 Fabrikam.database.windows.net.placeholder
。
DatabaseName
-
資料庫
string
。
AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal
時為必要項。
指定部署檔案的 Azure SQL 資料庫名稱。
DatabaseName
-
資料庫
string
。
AuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated
時為必要項。
指定部署檔案的 Azure SQL 資料庫名稱。
SqlUsername
-
登入
string
。
AuthenticationType = server
時為必要項。
指定 Azure SQL Server 系統管理員登入。
SqlPassword
-
密碼
string
。
AuthenticationType = server
時為必要項。
指定 Azure SQL Server 系統管理員的密碼。 接受建置或發行管線中定義的變數,$(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.placeholder;Database=testdb;User ID=AccountPlaceholder;Password=$(securePassword);
。
deployType
-
部署類型
輸入別名:TaskNameSelector
。
string
。 必須的。 允許的值:DacpacTask
(SQL DACPAC 檔案)、SqlTask
(SQL 腳本檔)、InlineSqlTask
(內嵌 SQL 腳本)。 預設值:DacpacTask
。
DeploymentAction
-
動作
string
。
TaskNameSelector = DacpacTask
時為必要項。 允許的值:Publish
、Extract
、Export
、Import
、Script
、DriftReport
(漂移報表)、DeployReport
(部署報表)。 預設值:Publish
。
從清單中指定其中一個 SQL 動作。 深入瞭解 SQL 動作清單。
DacpacFile
-
DACPAC 檔案
string
。
DeploymentAction = Publish || 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
。 必須的。 允許的值:AutoDetect
、IPAddressRange
。 預設值:AutoDetect
。
若要讓工作執行,自動化代理程式的IP位址必須新增至 Azure SQL Server 防火牆中 允許的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 Server 防火牆中的 [允許的IP位址] 清單中刪除 清單。
工作控制選項
除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制項選項和一般工作屬性。
輸出變數
此工作會定義下列 輸出變數,您可以在下游步驟、作業和階段中取用這些變數。
SqlDeploymentOutputFile
部署套件動作 Extract
、Export
、Script
、DriftReport
或 DeployReport
時產生的輸出檔案路徑。
備註
使用此工作來使用 DACPAC 部署 Azure SQL 資料庫,或使用 SQLCMD 執行腳本。
這很重要
只有在 Windows 環境中才支援這項工作。 如果您嘗試使用 Azure Active Directory (Azure AD) 整合式驗證,您必須建立私人代理程式。 託管代理程式不支援 Azure AD 整合式驗證。