SqlAzureDacpacDeployment@1 - Azure SQL 数据库部署 v1 任务

使用此任务通过 DACPAC 部署 Azure SQL 数据库,或使用 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 资源管理器)。 默认值:ConnectedServiceNameARM


azureClassicSubscription - Azure 经典订阅
输入别名ConnectedServiceName. stringConnectedServiceNameSelector = ConnectedServiceName时是必需的。

指定用于部署 SQL 文件的目标 Azure 经典订阅。


azureSubscription - Azure 订阅
输入别名ConnectedServiceNameARM. stringConnectedServiceNameSelector = ConnectedServiceNameARM时是必需的。

指定用于部署 SQL 文件的目标 Azure 资源管理器订阅。


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 服务器
stringAuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal时是必需的。

指定 Azure SQL Server 名称,例如 Fabrikam.database.windows.net.placeholder,1433Fabrikam.database.windows.net.placeholder


ServerName - Azure SQL 服务器
stringAuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated时是必需的。

指定 Azure SQL Server 名称,例如 Fabrikam.database.windows.net.placeholder,1433Fabrikam.database.windows.net.placeholder


DatabaseName - 数据库
stringAuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated || AuthenticationType = servicePrincipal时是必需的。

指定在其中部署文件的 Azure SQL 数据库的名称。


DatabaseName - 数据库
stringAuthenticationType = server || AuthenticationType = aadAuthenticationPassword || AuthenticationType = aadAuthenticationIntegrated时是必需的。

指定在其中部署文件的 Azure SQL 数据库的名称。


SqlUsername - 登录
stringAuthenticationType = server时是必需的。

指定 Azure SQL Server 管理员登录名。


SqlPassword - 密码
stringAuthenticationType = server时是必需的。

指定 Azure SQL Server 管理员的密码。 接受在生成或发布管道中定义的变量,$(passwordVariable)。 可以将变量类型标记为 secret 来保护它。


aadSqlUsername - 登录
stringAuthenticationType = aadAuthenticationPassword时是必需的。

指定 Active Directory 用户名。


aadSqlPassword - 密码
stringAuthenticationType = aadAuthenticationPassword时是必需的。

指定 Active Directory 用户的密码。 接受在生成或发布管道中定义的变量,$(passwordVariable)。 可以将变量类型标记为 secret 来保护它。


ConnectionString - 连接字符串
stringAuthenticationType = 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 - 操作
stringTaskNameSelector = DacpacTask时是必需的。 允许的值:PublishExtractExportImportScriptDriftReport(偏移报告)、DeployReport(部署报表)。 默认值:Publish

指定列表中的一个 SQL作。 详细了解 SQL作列表


DacpacFile - DACPAC 文件
stringDeploymentAction = Publish || DeploymentAction = Script || DeploymentAction = DeployReport时是必需的。

指定 DACPAC 文件在自动化代理上或自动化代理可访问的 UNC 路径上的位置,例如 \\BudgetIT\Web\Deploy\FabrikamDB.dacpac。 也可以使用预定义的系统变量(如 $(agent.releaseDirectory))。


BacpacFile - BACPAC 文件
stringDeploymentAction = Import时是必需的。

指定自动化代理上 BACPAC 文件的位置或自动化代理可访问的 UNC 路径,例如 \\BudgetIT\Web\Deploy\FabrikamDB.bacpac。 也可以使用预定义的系统变量(如 $(agent.releaseDirectory))。


SqlFile - SQL 脚本
stringTaskNameSelector = SqlTask时是必需的。

指定自动化代理或 UNC 路径上 SQL 脚本文件的位置,该路径可供自动化代理访问,例如 \\BudgetIT\Web\Deploy\FabrikamDB.sql。 也可以使用预定义的系统变量(如 $(agent.releaseDirectory))。


SqlInline - 内联 SQL 脚本
stringTaskNameSelector = 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 选项时将应用的其他 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 数据库上执行给定 SQL 查询时应用的附加 Invoke-Sqlcmd 参数,例如 -ConnectionTimeout 100 -OutputSqlErrors


IpDetectionMethod - 使用 指定防火墙规则
string。 必填。 允许的值:AutoDetectIPAddressRange。 默认值:AutoDetect

若要运行该任务,必须将自动化代理的 IP 地址添加到 Azure SQL Server 防火墙中 允许的 IP 地址。 选择“自动检测”以自动为自动化代理的可能 IP 地址范围自动添加防火墙例外,或显式指定范围。


StartIpAddress - 启动 IP 地址
stringIpDetectionMethod = IPAddressRange时是必需的。

指定自动化代理计算机池的起始 IP 地址,例如 196.21.30.50


EndIpAddress - 结束 IP 地址
stringIpDetectionMethod = IPAddressRange时是必需的。

指定自动化代理计算机池的结束 IP 地址,如 196.21.30.65


任务结束后 DeleteFirewallRule - 删除规则
boolean。 默认值:true

如果选中,任务结束后,此处指定的 IP 地址将从 Azure SQL Server 防火墙中的 允许的 IP 地址 列表中删除。


任务控制选项

除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性

输出变量

此任务定义以下 输出变量,可以在下游步骤、作业和阶段中使用。

SqlDeploymentOutputFile
部署包作 ExtractExportScriptDriftReportDeployReport时生成的输出文件路径。

注解

使用此任务可以使用 DACPAC 部署 Azure SQL 数据库,或使用 SQLCMD 运行脚本。

重要

此任务仅在 Windows 环境中受支持。 如果尝试使用 Azure Active Directory (Azure AD) 集成身份验证,则必须创建专用代理。 托管代理不支持 Azure AD 集成身份验证。

要求

要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理人
需求 自承载代理必须具有与以下 要求 运行使用此任务的作业 功能: sqlpackage
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 1.103.0 或更高版本
任务类别 部署