此任務將應用程式部署到 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
需求
| 要求 | 說明 |
|---|---|
| 管線類型 | YAML、傳統組建、傳統版本 |
| 執行於 | Agent、DeploymentGroup |
| 要求 | 沒有 |
| 能力 | 此工作不符合作業中後續工作的任何需求。 |
| 命令限制 | 任意 |
| Settable 變數 | 任意 |
| 代理程式版本 | 2.104.1 或更高版本 |
| 工作類別 | 部署 |