AzureRmWebAppDeployment@3 - Azure 应用服务部署 v3 任务

使用此任务可以使用 Docker、Java、.NET、.NET Core、Node.js、PHP、Python 或 Ruby 将 Web、移动或 API 应用部署到 Azure 应用服务。

此版本的任务已弃用;使用 AzureRmWebAppDeployment@4 利用 工作负荷标识联合等最新功能。

注释

使用 AzureFunctionApp@1 部署 Azure Functions 应用。

使用此任务可以使用 Docker、Java、.NET、.NET Core、Node.js、PHP、Python 或 Ruby 将 Web、移动或 API 应用部署到 Azure 应用服务。

注释

使用 AzureFunctionApp@1 部署 Azure Functions 应用。

语法

# Azure App Service deploy v3
# Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby.
- task: AzureRmWebAppDeployment@3
  inputs:
    azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription. 
    appType: 'app' # 'app' | 'applinux' | 'functionapp' | 'api' | 'mobileapp'. Alias: WebAppKind. Required. App type. Default: app.
    WebAppName: # string. Required. App Service name. 
    #DeployToSlotFlag: false # boolean. Optional. Use when WebAppKind != "". Deploy to slot. Default: false.
    #ResourceGroupName: # string. Required when DeployToSlotFlag = true. Resource group. 
    #SlotName: # string. Required when DeployToSlotFlag = true. Slot. 
    #ImageSource: 'Registry' # 'Registry' | 'Builtin'. Optional. Use when WebAppKind = applinux || WebAppKind = linux. Image Source. Default: Registry.
    #AzureContainerRegistry: # string. Required when ImageSource = AzureContainerRegistry. Registry. 
    #AzureContainerRegistryLoginServer: # string. Optional. Use when ImageSource = invalidimagesource. Registry Login Server Name. 
    #AzureContainerRegistryImage: # string. Required when ImageSource = AzureContainerRegistry. Image. 
    #AzureContainerRegistryTag: # string. Optional. Use when ImageSource = AzureContainerRegistry. Tag. 
    #DockerRepositoryAccess: 'public' # 'private' | 'public'. Required when ImageSource = invalidImage. Repository Access. Default: public.
    #dockerRegistryConnection: # string. Alias: RegistryConnectedServiceName. Required when DockerRepositoryAccess = private || ImageSource = PrivateRegistry. Registry Connection. 
    #PrivateRegistryImage: # string. Required when ImageSource = PrivateRegistry. Image. 
    #PrivateRegistryTag: # string. Optional. Use when ImageSource = PrivateRegistry. Tag. 
    #DockerNamespace: # string. Required when WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource  = Registry. Registry or Namespace. 
    #DockerRepository: # string. Required when WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource  = Registry. Image. 
    #DockerImageTag: # string. Optional. Use when WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource  = Registry. Tag. 
    #VirtualApplication: # string. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Virtual application. 
    #Package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required when WebAppKind != linux && WebAppKind != applinux &&  WebAppKind != "". Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #packageForLinux: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Alias: BuiltinLinuxPackage. Required when WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Builtin. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #RuntimeStack: # string. Required when WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Builtin. Runtime Stack. 
    #StartupCommand: # string. Optional. Use when WebAppKind = applinux || WebAppKind = linux. Startup command. 
  # Output
    #WebAppUri: # string. Optional. Use when WebAppKind != "". App Service URL. 
  # Post Deployment Action
    #ScriptType: # 'Inline Script' | 'File Path'. Optional. Use when WebAppKind != "". Deployment script type. 
    #InlineScript: ':: You can provide your deployment commands here. One command per line.' # string. Required when ScriptType == Inline Script && WebAppKind != "". Inline Script. Default: :: You can provide your deployment commands here. One command per line..
    #ScriptPath: # string. Required when ScriptType == File Path && WebAppKind != "". Deployment script path. 
  # File Transforms & Variable Substitution Options
    #GenerateWebConfig: false # boolean. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war. Generate Web.config. Default: false.
    #WebConfigParameters: # string. Required when GenerateWebConfig == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war. Web.config parameters. 
    #enableXmlTransform: false # boolean. Alias: XmlTransformation. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war. XML transformation. Default: false.
    #enableXmlVariableSubstitution: false # boolean. Alias: XmlVariableSubstitution. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war. XML variable substitution. Default: false.
    #JSONFiles: # string. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war. JSON variable substitution. 
  # Application and Configuration Settings
    #AppSettings: # string. App settings. 
    #ConfigurationSettings: # string. Configuration settings. 
  # Additional Deployment Options
    #TakeAppOfflineFlag: false # boolean. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Take App Offline. Default: false.
    #UseWebDeploy: false # boolean. Optional. Use when WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Publish using Web Deploy. Default: false.
    #SetParametersFile: # string. Optional. Use when UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". SetParameters file. 
    #RemoveAdditionalFilesFlag: false # boolean. Optional. Use when UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Remove additional files at destination. Default: false.
    #ExcludeFilesFromAppDataFlag: false # boolean. Optional. Use when UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Exclude files from the App_Data folder. Default: false.
    #AdditionalArguments: # string. Optional. Use when UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Additional arguments. 
    #RenameFilesFlag: false # boolean. Optional. Use when UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "". Rename locked files. Default: false.

输入

azureSubscription - Azure 订阅
输入别名:ConnectedServiceNamestring。 必填。

指定部署的 Azure 资源管理器订阅。


appType - 应用类型
输入别名:WebAppKindstring。 必填。 允许的值:app(Web 应用)、applinux(Linux Web 应用)、functionapp(不建议使用 Azure Functions 任务)、api(API 应用)、mobileapp(移动应用)。 默认值:app

指定要部署的 Web 应用的类型。

注意:为内置平台映像或自定义容器映像部署指定 Linux Web 应用。


appType - 应用类型
输入别名:WebAppKindstring。 必填。 允许的值:app(Web 应用)、applinux(Linux Web 应用)、functionapp(Function App)、api(API 应用)、mobileapp(移动应用)。 默认值:app

指定要部署的 Web 应用的类型。

注意:为内置平台映像或自定义容器映像部署指定 Linux Web 应用。


WebAppName - 应用服务名称
string。 必填。

指定现有 Azure 应用服务的名称。 仅当使用任务助手时,才会列出基于所选应用类型的应用服务。


DeployToSlotFlag - 部署到槽
boolean。 可选。 当 WebAppKind != ""时使用。 默认值:false

使用此选项可部署到生产槽以外的现有槽。 如果未选择此选项,Azure 应用服务将部署到生产槽。


ResourceGroupName - 资源组
stringDeployToSlotFlag = true时是必需的。

指定包含上面指定的 Azure 应用服务的 Azure 资源组。


SlotName -
stringDeployToSlotFlag = true时是必需的。

指定生产槽以外的现有槽。


ImageSource - 图像源
string。 可选。 当 WebAppKind = applinux || WebAppKind = linux时使用。 允许的值:Registry(容器注册表)、Builtin(内置映像)。 默认值:Registry

Linux 上的应用服务提供两种不同的选项来发布应用程序:

使用内置平台映像进行自定义映像部署或应用部署。


AzureContainerRegistry - 注册表
stringImageSource = AzureContainerRegistry时是必需的。

特定注册表的全局唯一顶级域名。

注意:完全限定的图像名称的格式为:<registry>/<repository><tag>。 例如,myregistry.azurecr.io/nginx:latest


AzureContainerRegistryLoginServer - 注册表登录服务器名称
string。 可选。 当 ImageSource = invalidimagesource时使用。

指定 Azure 容器注册表登录服务器名称。


AzureContainerRegistryImage - 图像
stringImageSource = AzureContainerRegistry时是必需的。

存储容器映像的存储库的名称。

注意:完全限定的图像名称的格式为:<registry>/<repository><tag>。 例如,myregistry.azurecr.io/nginxlatest


AzureContainerRegistryTag - 标记
string。 可选。 当 ImageSource = AzureContainerRegistry时使用。

这是注册表用来为 Docker 映像提供版本的机制。

注意:完全限定的图像名称的格式为:<registry>/<repository><tag>。 例如,myregistry.azurecr.io/nginxlatest


DockerRepositoryAccess - 存储库访问
stringImageSource = invalidImage时是必需的。 允许的值:privatepublic。 默认值:public

指定 Docker 存储库访问权限。


dockerRegistryConnection - 注册表连接
输入别名:RegistryConnectedServiceNamestringDockerRepositoryAccess = private || ImageSource = PrivateRegistry时是必需的。

指定注册表连接。


PrivateRegistryImage - 图像
stringImageSource = PrivateRegistry时是必需的。

存储容器映像的存储库的名称。

注意:完全限定的图像名称的格式为:<registry><repository><tag>。 例如,myregistry.azurecr.io/nginxlatest


PrivateRegistryTag - 标记
string。 可选。 当 ImageSource = PrivateRegistry时使用。

标记是注册表用来为 Docker 映像提供版本的机制。

注意:完全限定的图像名称的格式为:“<registry>/<repository><tag>”。 例如,myregistry.azurecr.io/nginxlatest


DockerNamespace - 注册表或命名空间
stringWebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Registry时是必需的。

特定注册表或命名空间的全局唯一顶级域名。

注意:完全限定的图像名称的格式为:<registry or namespace>/<repository><tag>。 例如,myregistry.azurecr.io/nginxlatest


DockerRepository - 图像
stringWebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Registry时是必需的。

存储容器映像的存储库的名称。

注意:完全限定的图像名称的格式为:“<registry or namespace>/<repository><tag>。 例如,myregistry.azurecr.io/nginxlatest


DockerImageTag - 标记
string。 可选。 当 WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Registry时使用。

这是注册表用来为 Docker 映像提供版本的机制。

注意:完全限定的图像名称的格式为:“<registry or namespace>/<repository><tag>”。 例如,myregistry.azurecr.io/nginxlatest


VirtualApplication - 虚拟应用程序
string。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。

指定已在 Azure 门户中配置的虚拟应用程序的名称。 部署到应用服务根目录时不需要此选项。


Package - 包或文件夹
stringWebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时是必需的。 默认值:$(System.DefaultWorkingDirectory)/**/*.zip

包或文件夹的文件路径,其中包含由 MSBuild 或压缩的 zip 或 war 文件生成的应用服务内容。

变量 生成发布。 支持 通配符

例如,$(System.DefaultWorkingDirectory)/\*\*/\*.zip$(System.DefaultWorkingDirectory)/\*\*/\*.war


packageForLinux - 包或文件夹
输入别名:BuiltinLinuxPackagestringWebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Builtin时是必需的。 默认值:$(System.DefaultWorkingDirectory)/**/*.zip

包或文件夹的文件路径,其中包含由 MSBuild 或压缩的 zip 或 war 文件生成的应用服务内容。

变量 生成发布。 支持 通配符

例如,$(System.DefaultWorkingDirectory)/\*\*/\*.zip$(System.DefaultWorkingDirectory)/\*\*/\*.war


RuntimeStack - Runtime Stack
stringWebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Builtin时是必需的。

指定框架和版本。


StartupCommand - Startup 命令
string。 可选。 当 WebAppKind = applinux || WebAppKind = linux时使用。

指定启动命令。


WebAppUri - 应用服务 URL
string。 可选。 当 WebAppKind != ""时使用。

指定为 Azure 应用服务的 URL 生成的输出变量的名称。 该变量可用于后续任务。


ScriptType - 部署脚本类型
string。 可选。 当 WebAppKind != ""时使用。 允许的值:Inline ScriptFile Path(脚本文件路径)。

通过提供一个脚本来自定义部署,该脚本将在任务成功完成部署后在 Azure 应用服务上运行。 例如,这可以还原 Node、PHP 和 Python 应用程序的包。 详细了解 Azure 应用服务部署


InlineScript - 内联脚本
stringScriptType == Inline Script && WebAppKind != ""时是必需的。 默认值::: You can provide your deployment commands here. One command per line.


ScriptPath - 部署脚本路径
stringScriptType == File Path && WebAppKind != ""时是必需的。


GenerateWebConfig - 生成 Web.config
boolean。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war时使用。 默认值:false

如果应用程序没有标准 Web.config,将生成并部署到 Azure 应用服务。 可以编辑 web.config 中的值,并根据应用程序框架而有所不同。 例如,对于 node.js 应用程序,web.config 将具有启动文件和 iis_node 模块值。 详细了解 Azure 应用服务部署


WebConfigParameters - Web.config 参数
stringGenerateWebConfig == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war时是必需的。

编辑生成的 web.config 文件中的启动文件等值。 此编辑功能仅适用于生成的 web.config。 详细了解 Azure 应用服务部署


AppSettings - 应用设置
string

按照语法 -key 值编辑 Web 应用应用程序设置。 包含空格的值应用双引号引起来。 示例:-Port 5000-RequestTimeout 5000-WEBSITE_TIME_ZONE"Eastern Standard Time"


ConfigurationSettings - 配置设置
string

按照语法 -key 值编辑 Web 应用配置设置。 包含空格的值应用双引号引起来。

示例:-phpVersion 5.6-linuxFxVersion: node|6.11


TakeAppOfflineFlag - 使应用脱机
boolean。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。 默认值:false

在同步作开始之前,使用此选项可将 app_offline.htm 文件置于应用服务的根目录中,使 Azure 应用服务脱机。 同步作成功完成后,将删除该文件。


使用 Web 部署UseWebDeploy - 发布
boolean。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。 默认值:false

仅当使用 Windows 代理时,才支持 Publish using Web Deploy 选项。 在其他平台上,该任务依赖于 Kudu REST API 来部署 Azure 应用服务,并且不支持以下选项。


SetParametersFile - SetParameters 文件
string。 可选。 当 UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。

要使用的 SetParameters.xml 文件的位置。


RemoveAdditionalFilesFlag - 在目标 删除其他文件
boolean。 可选。 当 UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。 默认值:false

使用此选项可删除 Azure 应用服务中没有匹配文件的文件。

注意:这还将删除与此 Azure 应用服务上安装的任何扩展相关的所有文件。 若要防止出现这种情况,请选中 Exclude files from App_Data folder 复选框。


ExcludeFilesFromAppDataFlag - 从App_Data文件夹中排除文件
boolean。 可选。 当 UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。 默认值:false

使用此选项可防止将 App_Data 文件夹中的文件部署到/从 Azure 应用服务中删除。


AdditionalArguments - 其他参数
string。 可选。 当 UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。

语法 -key:value后面的其他 Web 部署参数。

部署 Azure 应用服务时将应用这些应用。 示例:-disableLink:AppPoolExtension-disableLink:ContentExtension

请参阅 Web 部署作设置的更多示例。


RenameFilesFlag - 重命名锁定的文件
boolean。 可选。 当 UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""时使用。 默认值:false

使用此选项可在 Azure 应用服务应用程序设置中启用 msdeploy 标志 MSDEPLOY_RENAME_LOCKED_FILES=1。 该选项使 msdeploy 能够重命名在应用部署期间锁定的文件。


enableXmlTransform - XML 转换
输入别名:XmlTransformationboolean。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war时使用。 默认值:false

配置转换将在 *.Release.config上运行 *.<EnvironmentName>.config*.config file

配置转换将在变量替换之前运行。

XML 转换仅适用于 Windows 平台。


enableXmlVariableSubstitution - XML 变量替换
输入别名:XmlVariableSubstitutionboolean。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war时使用。 默认值:false

生成或发布管道中定义的变量将与任何配置文件和 parameters.xmlappSettingsapplicationSettingsconnectionStrings 节中的 keyname 项匹配。 变量替换在配置转换后运行。

注意:如果在发布管道和环境中定义了相同的变量,则环境变量将取代发布管道变量。


JSONFiles - JSON 变量替换
string。 可选。 当 WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war时使用。

提供 JSON 文件的新行分隔列表,以替换变量值。 文件名相对于根文件夹提供。

若要替换嵌套或分层的 JSON 变量,请使用 JSONPath 表达式指定它们。

例如,若要替换以下示例中 ConnectionString 的值,需要在生成/发布管道(或发布管道的环境)中将变量定义为 Data.DefaultConnection.ConnectionString

{
  "Data": {
    "DefaultConnection": {
      "ConnectionString": "Server=(localdb)\SQLEXPRESS;Database=MyDB;Trusted_Connection=True"
    }
  }
}

变量替换在配置转换后运行。

注意:管道变量在替换中排除。


任务控制选项

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

输出变量

没有。

注解

此任务有较新版本可用。 有关详细信息,请参阅 AzureRmWebAppDeployment@4

故障排除

无法使用 Windows 代理中的 Microsoft Entra ID 身份验证将 Web 部署到 Azure 应用服务

Azure 应用服务部署任务支持使用 Microsoft Entra ID 连接到 Microsoft Azure,除非存在以下三个条件:

  • 你在 Windows 代理上使用 Web 部署包格式
  • 代理运行的是旧版 msdeploy.exe(例如,使用 windows-2019 托管代理映像时)
  • Azure 应用服务已禁用基本身份验证

如果存在这三个条件,将收到类似于 App Service is configured to not use basic authentication. This requires Web Deploy msdeploy.exe version 7.1.7225.2108 or higher. You need a version of Visual Studio that includes an updated version of msdeploy.exe. For more information, visit https://aka.ms/azdo-webapp-msdeploy.

若要解决此问题,可以按首选项顺序从以下选项中进行选择。

  1. 更新代理映像。 如果使用托管代理,请从 windows-2019 移动到 windows-2022(或 windows 最新)。 如果使用自承载代理,请在代理上安装 Visual Studio 2022 以获取较新版本的 msdeploy.exe
  2. 如果依赖于较旧的代理映像,并且无法更新管道的代理,请考虑拆分作业,以便 Azure 应用服务部署任务在 windows-2022 上运行(或 windows 最新)。
  3. 如果这两个选项都不可能,则可以 为 Azure 应用服务启用基本身份验证

要求

要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.104.1 或更高版本
任务类别 部署