此任务将应用程序部署到 Azure Spring Apps 并管理这些部署。
重要
Azure Spring Apps Basic/Standard 和 Enterprise 计划支持此任务。 有关详细信息,请参阅 自动将应用程序部署到 Azure Spring Apps。
语法
# Azure Spring Apps v0
# Deploy applications to Azure Spring Apps and manage deployments.
- task: AzureSpringCloud@0
inputs:
azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription.
Action: 'Deploy' # 'Deploy' | 'Set Production' | 'Delete Staging Deployment'. Required. Action. Default: Deploy.
AzureSpringCloud: # string. Required. Azure Spring Apps Name.
AppName: # string. Required. App.
#DeploymentType: 'Artifacts' # 'Artifacts' | 'CustomContainer'. Optional. Use when Action = Deploy. Deployment Type. Default: Artifacts.
#UseStagingDeployment: true # boolean. Optional. Use when Action = Deploy || Action = Set Production. Use Staging Deployment. Default: true.
#CreateNewDeployment: false # boolean. Optional. Use when Action = Deploy && UseStagingDeployment = false. Create a new staging deployment if one does not exist. Default: false.
#DeploymentName: # string. Optional. Use when UseStagingDeployment = false && Action != Delete Staging Deployment. Deployment.
#Package: '$(System.DefaultWorkingDirectory)/**/*.jar' # string. Optional. Use when Action = Deploy && DeploymentType = Artifacts. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.jar.
#RegistryServer: 'docker.io' # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Registry Server. Default: docker.io.
#RegistryUsername: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Registry Username.
#RegistryPassword: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Registry Password.
#ImageName: 'hello-world:v1' # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Image Name and Tag. Default: hello-world:v1.
#ImageCommand: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Image Command.
#ImageArgs: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Image Arguments.
#ImageLanguageFramework: # 'springboot'. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Language Framework.
# Application and Configuration Settings
#Builder: # string. Optional. Use when Action = Deploy && DeploymentType = Artifacts. Builder.
#EnvironmentVariables: # string. Optional. Use when Action = Deploy. Environment Variables.
#JvmOptions: # string. Optional. Use when Action = Deploy && DeploymentType = Artifacts. JVM Options.
#RuntimeVersion: 'Java_11' # 'Java_8' | 'Java_11' | 'Java_17' | 'Java_21' | 'NetCore_31'. Optional. Use when Action = Deploy && DeploymentType = Artifacts. Runtime Version. Default: Java_11.
#DotNetCoreMainEntryPath: # string. Optional. Use when RuntimeVersion = NetCore_31. Main Entry Path.
#Version: # string. Optional. Use when Action = Deploy. Version.
# Azure Spring Apps v0
# Deploy applications to Azure Spring Apps and manage deployments.
- task: AzureSpringCloud@0
inputs:
azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription.
Action: 'Deploy' # 'Deploy' | 'Set Production' | 'Delete Staging Deployment'. Required. Action. Default: Deploy.
AzureSpringCloud: # string. Required. Azure Spring Apps Name.
AppName: # string. Required. App.
#DeploymentType: 'Artifacts' # 'Artifacts' | 'CustomContainer'. Optional. Use when Action = Deploy. Deployment Type. Default: Artifacts.
#UseStagingDeployment: true # boolean. Optional. Use when Action = Deploy || Action = Set Production. Use Staging Deployment. Default: true.
#CreateNewDeployment: false # boolean. Optional. Use when Action = Deploy && UseStagingDeployment = false. Create a new staging deployment if one does not exist. Default: false.
#DeploymentName: # string. Optional. Use when UseStagingDeployment = false && Action != Delete Staging Deployment. Deployment.
#Package: '$(System.DefaultWorkingDirectory)/**/*.jar' # string. Optional. Use when Action = Deploy && DeploymentType = Artifacts. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.jar.
#RegistryServer: 'docker.io' # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Registry Server. Default: docker.io.
#RegistryUsername: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Registry Username.
#RegistryPassword: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Registry Password.
#ImageName: 'hello-world:v1' # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Image Name and Tag. Default: hello-world:v1.
#ImageCommand: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Image Command.
#ImageArgs: # string. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Image Arguments.
#ImageLanguageFramework: # 'springboot'. Optional. Use when Action = Deploy && DeploymentType = CustomContainer. Language Framework.
# Application and Configuration Settings
#Builder: # string. Optional. Use when Action = Deploy && DeploymentType = Artifacts. Builder.
#EnvironmentVariables: # string. Optional. Use when Action = Deploy. Environment Variables.
#JvmOptions: # string. Optional. Use when Action = Deploy && DeploymentType = Artifacts. JVM Options.
#RuntimeVersion: 'Java_11' # 'Java_8' | 'Java_11' | 'NetCore_31'. Optional. Use when Action = Deploy && DeploymentType = Artifacts. Runtime Version. Default: Java_11.
#DotNetCoreMainEntryPath: # string. Optional. Use when RuntimeVersion = NetCore_31. Main Entry Path.
#Version: # string. Optional. Use when Action = Deploy. Version.
# Azure Spring Apps v0
# Deploy applications to Azure Spring Apps and manage deployments.
- task: AzureSpringCloud@0
inputs:
azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription.
Action: 'Deploy' # 'Deploy' | 'Set Production' | 'Delete Staging Deployment'. Required. Action. Default: Deploy.
AzureSpringCloud: # string. Required. Azure Spring Apps Name.
AppName: # string. Required. App.
#UseStagingDeployment: true # boolean. Optional. Use when Action = Deploy || Action = Set Production. Use Staging Deployment. Default: true.
#CreateNewDeployment: false # boolean. Optional. Use when Action = Deploy && UseStagingDeployment = false. Create a new staging deployment if one does not exist. Default: false.
#DeploymentName: # string. Optional. Use when UseStagingDeployment = false && Action != Delete Staging Deployment. Deployment.
#Package: '$(System.DefaultWorkingDirectory)/**/*.jar' # string. Optional. Use when Action = Deploy. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.jar.
# Application and Configuration Settings
#EnvironmentVariables: # string. Optional. Use when Action = Deploy. Environment Variables.
#JvmOptions: # string. Optional. Use when Action = Deploy. JVM Options.
#RuntimeVersion: 'Java_11' # 'Java_8' | 'Java_11' | 'NetCore_31'. Optional. Use when Action = Deploy. Runtime Version. Default: Java_11.
#DotNetCoreMainEntryPath: # string. Optional. Use when RuntimeVersion = NetCore_31. Main Entry Path.
#Version: # string. Optional. Use when Action = Deploy. Version.
输入
azureSubscription
-
Azure 订阅
输入别名: ConnectedServiceName.
string。 必填。
指定部署的 Azure Resource Manager 订阅 。
Action
-
操作
string。 必填。 允许的值: Deploy, Set Production (Set Production Deployment), Delete Staging Deployment. 默认值:Deploy。
要在 Azure Spring Apps 上执行的作。
AzureSpringCloud
-
Azure Spring Apps 名称
string。 必填。
要部署的 Azure Spring Apps 实例的名称或资源 ID。
AppName
-
应用程序
string。 必填。
要部署的 Azure Spring Apps 应用的名称。 应用程序必须在任务执行之前存在。
DeploymentType
-
部署类型
string。 可选。 当 Action = Deploy时使用。 允许的值: Artifacts、 CustomContainer (自定义容器)。 默认值:Artifacts。
要使用源代码或 Java 包进行部署,请选择 “Artifacts”;要使用容器映像进行部署,请选择“自定义容器”。
UseStagingDeployment
-
使用暂存部署
boolean。 可选。 当 Action = Deploy || Action = Set Production时使用。 默认值:true。
在任务运行时,此输入会自动选择设置为 staging.
如果设置为 true,则将任务应用于在执行时设置为暂存部署的 部署 。 如果省略, DeploymentName 则必须设置该参数。
CreateNewDeployment
-
创建新的暂存部署(如果不存在)。
boolean。 可选。 当 Action = Deploy && UseStagingDeployment = false时使用。 默认值:false。
如果设置为 true,并且 指定的 DeploymentName 部署在执行时不存在,则会创建该部署。 如果省略, DeploymentName 则必须设置该参数。
DeploymentName
-
部署
string。 可选。 当 UseStagingDeployment = false && Action != Delete Staging Deployment时使用。
此任务将应用于的 部署 。 如果不使用蓝绿部署,请将此字段设置为 default。 该值必须以字母开头,并且仅包含小写字母和数字。
Package
-
包或文件夹
string。 可选。 当 Action = Deploy && DeploymentType = Artifacts时使用。 默认值:$(System.DefaultWorkingDirectory)/**/*.jar。
包含 Azure Spring Apps 应用内容的包或文件夹的文件路径(.jar 适用于 Java 的文件、 .zip 适用于 .NET Core)。
支持变量( 生成 | 发布)和通配符。
例如: $(System.DefaultWorkingDirectory)/**/*.jar
Package
-
包或文件夹
string。 可选。 当 Action = Deploy时使用。 默认值:$(System.DefaultWorkingDirectory)/**/*.jar。
包含 Azure Spring Apps 应用内容的包或文件夹的文件路径(.jar 适用于 Java 的文件、 .zip 适用于 .NET Core)。
支持变量( 生成 | 发布)和通配符。
例如: $(System.DefaultWorkingDirectory)/**/*.jar
Builder
-
建筑工人
string。 可选。 当 Action = Deploy && DeploymentType = Artifacts时使用。
选择 VMware Tanzu® Build Service™ 的构建器,这可以在企业层中使用。
有关详细说明,请查看 使用 Tanzu Build Service。
RegistryServer
-
注册表服务器
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。 默认值:docker.io。
容器映像的注册表。 默认值:docker.io。
RegistryUsername
-
注册表用户名
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。
容器注册表的用户名。
RegistryPassword
-
注册表密码
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。
容器注册表的密码。
ImageName
-
图像名称和标记
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。 默认值:hello-world:v1。
容器映像标记。
ImageCommand
-
Image 命令
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。
容器映像的命令。
ImageArgs
-
图像参数
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。
容器映像的参数。
ImageLanguageFramework
-
语言框架
string。 可选。 当 Action = Deploy && DeploymentType = CustomContainer时使用。 允许的值: springboot.
EnvironmentVariables
-
环境变量
string。 可选。 当 Action = Deploy时使用。
要使用语法 -key value 输入的环境变量(例如: -CUSTOMER_NAME Contoso-WEBSITE_TIME_ZONE)。 包含空格的值应用双引号括起来(例如: "Eastern Standard Time")。
JvmOptions
-
JVM 选项
string。 可选。 当 Action = Deploy && DeploymentType = Artifacts时使用。
编辑应用程序的 JVM 选项。 包含 JVM 选项的字符串,例如 -Xms1024m -Xmx2048m.
JvmOptions
-
JVM 选项
string。 可选。 当 Action = Deploy时使用。
编辑应用程序的 JVM 选项。 包含 JVM 选项的字符串,例如 -Xms1024m -Xmx2048m.
RuntimeVersion
-
运行时版本
string。 可选。 当 Action = Deploy && DeploymentType = Artifacts时使用。 允许的值: Java_8 (Java 8)、 Java_11 (Java 11)、 Java_17 (Java 17)、 Java_21 (Java 21)、 NetCore_31 (.Net Core 3.1)。 默认值:Java_11。
应用程序将在其上运行的运行时版本。
RuntimeVersion
-
运行时版本
string。 可选。 当 Action = Deploy && DeploymentType = Artifacts时使用。 允许的值: Java_8 (Java 8)、 Java_11 (Java 11)、 NetCore_31 (.Net Core 3.1)。 默认值:Java_11。
应用程序将在其上运行的运行时版本。
RuntimeVersion
-
运行时版本
string。 可选。 当 Action = Deploy时使用。 允许的值: Java_8 (Java 8)、 Java_11 (Java 11)、 NetCore_31 (.Net Core 3.1)。 默认值:Java_11。
应用程序将在其上运行的运行时版本。
DotNetCoreMainEntryPath
-
主入口路径
string。 可选。 当 RuntimeVersion = NetCore_31时使用。
相对于 zip 根目录的 .NET 可执行文件的路径。
Version
-
版本
string。 可选。 当 Action = Deploy时使用。
部署版本。 如果未设置,则版本保持不变。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 “控制”选项和常见任务属性。
输出变量
此任务定义了以下 输出变量,可以在下游步骤、作业和阶段中使用这些变量。
testEndpoint
仅在 'Deploy'作之后。 包含用于访问更新的部署的私有 URL。
注解
使用此任务可将应用程序部署到 Azure Spring Apps 并管理 Azure Spring Cloud 部署。
重要
Azure Spring Apps Basic/Standard 和 Enterprise 计划支持此任务。 有关详细信息,请参阅 自动将应用程序部署到 Azure Spring Apps。
例子
以下示例演示常见使用方案。 有关详细信息,请参阅 自动将应用程序部署到 Azure Spring Apps。
删除暂存部署
“Delete Staging Deployment”作允许您删除未接收生产流量的部署。 这将释放该部署使用的资源,并为新的暂存部署腾出空间:
variables:
azureSubscription: Contoso
steps:
- task: AzureSpringCloud@0
continueOnError: true # Don't fail the pipeline if a staging deployment doesn't already exist.
inputs:
continueOnError: true
inputs:
azureSubscription: $(azureSubscription)
Action: 'Delete Staging Deployment'
AppName: customer-api
AzureSpringCloud: contoso-dev-az-spr-cld
正在部署
到生产环境
以下示例部署到 Azure Spring Apps 中的默认生产部署。 这是使用基本 SKU 时唯一可能的部署方案:
注释
包搜索模式应该只返回一个包。 如果生成任务生成多个 JAR 包(如 sources.jar 和 javadoc.jar),则需要优化搜索模式,使其仅匹配应用程序二进制项目。
variables:
azureSubscription: Contoso
steps:
- task: AzureSpringCloud@0
inputs:
azureSubscription: $(azureSubscription)
Action: 'Deploy'
AzureSpringCloud: contoso-dev-az-spr-cld
AppName: customer-api
UseStagingDeployment: false
DeploymentName: default
Package: '$(System.DefaultWorkingDirectory)/**/*customer-api*.jar'
蓝绿色
以下示例部署到预先存在的暂存部署。 此部署在设置为生产部署之前不会接收生产流量。
variables:
azureSubscription: Contoso
steps:
- task: AzureSpringCloud@0
inputs:
azureSubscription: $(azureSubscription)
Action: 'Deploy'
AzureSpringCloud: contoso-dev-az-spr-cld
AppName: customer-api
UseStagingDeployment: true
Package: '$(System.DefaultWorkingDirectory)/**/*customer-api*.jar'
有关蓝绿部署的更多信息,包括替代方法,请参阅 蓝绿部署策略。
设置生产部署
以下示例将当前暂存部署设置为生产部署,有效地交换接收生产流量的部署。
variables:
azureSubscription: Contoso
steps:
- task: AzureSpringCloud@0
inputs:
azureSubscription: $(azureSubscription)
Action: 'Set Production'
AzureSpringCloud: contoso-dev-az-spr-cld
AppName: customer-api
UseStagingDeployment: true