使用此工作,使用 Docker、Java、.NET、.NET Core、Node.js、PHP、Python 或 Ruby 部署至 Azure App Service Web、行動或 API 應用程式。
此版本的工作已被取代;使用 AzureRmWebAppDeployment@4 利用 工作負載身分識別同盟等最新功能。
備註
使用 AzureFunctionApp@1 來部署 Azure Functions 應用程式。
使用此工作,使用 Docker、Java、.NET、.NET Core、Node.js、PHP、Python 或 Ruby 部署至 Azure App Service Web、行動或 API 應用程式。
備註
使用 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 訂用帳戶
輸入別名:ConnectedServiceName
。
string
。 必須的。
指定部署的 Azure Resource Manager 訂用帳戶。
appType
-
應用程式類型
輸入別名:WebAppKind
。
string
。 必須的。 允許的值:app
(Web 應用程式)、applinux
(Linux Web 應用程式)、functionapp
(不建議使用 Azure Functions 工作)、api
(API 應用程式)、mobileapp
(行動應用程式)。 預設值:app
。
指定要部署的 Web 應用程式類型。
注意:為內建平臺映像或自定義容器映像部署指定Linux Web 應用程式。
appType
-
應用程式類型
輸入別名:WebAppKind
。
string
。 必須的。 允許的值:app
(Web 應用程式)、applinux
(Linux Web 應用程式)、functionapp
(函式應用程式)、api
(API 應用程式)、mobileapp
(行動應用程式)。 預設值:app
。
指定要部署的 Web 應用程式類型。
注意:為內建平臺映像或自定義容器映像部署指定Linux Web 應用程式。
WebAppName
-
App Service 名稱
string
。 必須的。
指定現有 Azure App Service 的名稱。 只有在使用工作助理時,才會列出以所選應用程式類型為基礎的應用程式服務。
DeployToSlotFlag
-
部署至位置
boolean
。 選擇性。
WebAppKind != ""
時使用 。 預設值:false
。
使用此選項可部署到生產位置以外的現有位置。 如果未選取此選項,則會將 Azure App Service 部署至生產位置。
ResourceGroupName
-
資源群組
string
。
DeployToSlotFlag = true
時為必要項。
指定包含上面指定之 Azure App Service 的 Azure 資源群組。
SlotName
-
位置
string
。
DeployToSlotFlag = true
時為必要項。
指定生產位置以外的現有位置。
ImageSource
-
影像來源
string
。 選擇性。
WebAppKind = applinux || WebAppKind = linux
時使用 。 允許的值:Registry
(Container Registry),Builtin
(內建映射)。 預設值:Registry
。
Linux 上的 App Service 提供兩種不同的選項來發布您的應用程式:
使用內建平臺映像的自定義映射部署或應用程式部署。
AzureContainerRegistry
-
登錄
string
。
ImageSource = AzureContainerRegistry
時為必要項。
您特定登錄的全域唯一最上層功能變數名稱。
注意:完整映像名稱的格式為:<registry>
/<repository>
:<tag>
。 例如,myregistry.azurecr.io
/nginx:latest
。
AzureContainerRegistryLoginServer
-
登錄登入伺服器名稱
string
。 選擇性。
ImageSource = invalidimagesource
時使用 。
指定 Azure Container Registry 登入伺服器名稱。
AzureContainerRegistryImage
-
映像
string
。
ImageSource = AzureContainerRegistry
時為必要項。
儲存容器映像的存放庫名稱。
注意:完整映像名稱的格式為:<registry>
/<repository>
:<tag>
。 例如,myregistry.azurecr.io
/nginx
:latest
。
AzureContainerRegistryTag
-
標籤
string
。 選擇性。
ImageSource = AzureContainerRegistry
時使用 。
這是登錄用來為 Docker 映像提供版本的機制。
注意:完整映像名稱的格式為:<registry>
/<repository>
:<tag>
。 例如,myregistry.azurecr.io
/nginx
:latest
。
DockerRepositoryAccess
-
存放庫存取
string
。
ImageSource = invalidImage
時為必要項。 允許的值:private
、public
。 預設值:public
。
指定 Docker 存放庫存取權。
dockerRegistryConnection
-
登錄連線
輸入別名:RegistryConnectedServiceName
。
string
。
DockerRepositoryAccess = private || ImageSource = PrivateRegistry
時為必要項。
指定登錄連線。
PrivateRegistryImage
-
映像
string
。
ImageSource = PrivateRegistry
時為必要項。
儲存容器映像的存放庫名稱。
注意:完整映像名稱的格式如下:<registry>
<repository>
:<tag>
。 例如,myregistry.azurecr.io
/nginx
:latest
。
PrivateRegistryTag
-
標籤
string
。 選擇性。
ImageSource = PrivateRegistry
時使用 。
標籤是登錄用來為 Docker 映像提供版本的機制。
注意:完整映射名稱的格式為: '<registry>
/<repository>
:<tag>
'。 例如,myregistry.azurecr.io
/nginx
:latest
。
DockerNamespace
-
登錄或命名空間
string
。
WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Registry
時為必要項。
特定登錄或命名空間的全域唯一最上層功能變數名稱。
注意:完整映像名稱的格式為:<registry or namespace>
/<repository>
:<tag>
。 例如,myregistry.azurecr.io
/nginx
:latest
。
DockerRepository
-
映像
string
。
WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Registry
時為必要項。
儲存容器映像的存放庫名稱。
注意:完整映像名稱的格式為:'<registry or namespace>
/<repository>
:<tag>
。 例如,myregistry.azurecr.io
/nginx
:latest
。
DockerImageTag
-
標籤
string
。 選擇性。
WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Registry
時使用 。
這是登錄用來為 Docker 映像提供版本的機制。
注意:完整映射名稱的格式為: '<registry or namespace>
/<repository>
:<tag>
'。 例如,myregistry.azurecr.io
/nginx
:latest
。
VirtualApplication
-
虛擬應用程式
string
。 選擇性。
WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。
指定已在 Azure 入口網站中設定的虛擬應用程式名稱。 部署至 App Service 根目錄時不需要此選項。
Package
-
套件或資料夾
string
。
WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時為必要項。 預設值:$(System.DefaultWorkingDirectory)/**/*.zip
。
封裝或資料夾的檔案路徑,包含 MSBuild 或壓縮的 zip 或 war 檔案所產生的 App Service 內容。
例如,$(System.DefaultWorkingDirectory)/\*\*/\*.zip
或 $(System.DefaultWorkingDirectory)/\*\*/\*.war
。
packageForLinux
-
套件或資料夾
輸入別名:BuiltinLinuxPackage
。
string
。
WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Builtin
時為必要項。 預設值:$(System.DefaultWorkingDirectory)/**/*.zip
。
封裝或資料夾的檔案路徑,包含 MSBuild 或壓縮的 zip 或 war 檔案所產生的 App Service 內容。
例如,$(System.DefaultWorkingDirectory)/\*\*/\*.zip
或 $(System.DefaultWorkingDirectory)/\*\*/\*.war
。
RuntimeStack
-
Runtime Stack
string
。
WebAppKind != app && WebAppKind != functionapp && WebAppKind != api && WebAppKind != mobileapp && ImageSource = Builtin
時為必要項。
指定架構和版本。
StartupCommand
-
啟動命令
string
。 選擇性。
WebAppKind = applinux || WebAppKind = linux
時使用 。
指定啟動命令。
WebAppUri
-
App Service URL
string
。 選擇性。
WebAppKind != ""
時使用 。
指定為 Azure App Service URL 所產生的輸出變數名稱。 變數可用於後續工作。
ScriptType
-
部署文本類型
string
。 選擇性。
WebAppKind != ""
時使用 。 允許的值:Inline Script
、File Path
(文稿檔案路徑)。
藉由提供腳本,在工作順利完成部署之後,在 Azure App Service 上執行,以自定義部署。 例如,這可以還原 Node、PHP 和 Python 應用程式的套件。 深入瞭解 azure App Service 部署
InlineScript
-
內嵌腳本
string
。
ScriptType == Inline Script && WebAppKind != ""
時為必要項。 預設值::: You can provide your deployment commands here. One command per line.
。
ScriptPath
-
部署腳本路徑
string
。
ScriptType == File Path && WebAppKind != ""
時為必要項。
GenerateWebConfig
-
產生 Web.config
boolean
。 選擇性。
WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war
時使用 。 預設值:false
。
如果應用程式沒有標準 Web.config
,則會產生並部署至 Azure App Service。
web.config
中的值可以編輯,並根據應用程式架構而有所不同。 例如,針對 node.js
應用程式,web.config
會有啟動檔案和 iis_node
模組值。 深入瞭解 azure App Service 部署
WebConfigParameters
-
Web.config 參數
string
。
GenerateWebConfig == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war
時為必要項。
編輯產生的 web.config
檔案中的啟動檔案等值。 這項編輯功能僅適用於產生的 web.config
。 深入瞭解 azure App Service 部署
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
檔案放在 App Service 的根目錄中,讓 Azure App Service 離線。 同步作業成功完成之後,將會移除檔案。
使用 Web DeployUseWebDeploy
- 發佈
boolean
。 選擇性。
WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。 預設值:false
。
只有在使用 Windows 代理程式時,才支援 Publish using Web Deploy
選項。 在其他平臺上,工作依賴 Kudu REST API 來部署 Azure App Service,而且不支援下列選項。
SetParametersFile
-
SetParameters 檔案
string
。 選擇性。
UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。
要使用的 SetParameters.xml
檔案位置。
RemoveAdditionalFilesFlag
-
在目的地 移除其他檔案
boolean
。 選擇性。
UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。 預設值:false
。
使用此選項可刪除 Azure App Service 上沒有相符檔案的 App Service 套件或資料夾中的檔案。
注意:這也會移除與此 Azure App Service 上安裝之任何擴充功能相關的所有檔案。 若要避免這種情況,請選取 [Exclude files from App_Data folder
] 複選框。
ExcludeFilesFromAppDataFlag
-
從App_Data資料夾排除檔案
boolean
。 選擇性。
UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。 預設值:false
。
使用此選項可防止 App_Data
資料夾中的檔案從 Azure App Service 部署/刪除。
AdditionalArguments
-
其他自變數
string
。 選擇性。
UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。
語法 -key:value
之後的其他Web Deploy自變數。
部署 Azure App Service 時,將會套用這些專案。 範例:-disableLink:AppPoolExtension
-disableLink:ContentExtension
。
RenameFilesFlag
-
重新命名鎖定的檔案
boolean
。 選擇性。
UseWebDeploy == true && WebAppKind != linux && WebAppKind != applinux && WebAppKind != ""
時使用 。 預設值:false
。
使用此選項可在 Azure App Service 應用程式設定中啟用 msdeploy 旗標 MSDEPLOY_RENAME_LOCKED_FILES=1
。 這個選項可讓 msdeploy 重新命名在應用程式部署期間鎖定的檔案。
enableXmlTransform
-
XML 轉換
輸入別名:XmlTransformation
。
boolean
。 選擇性。
WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war
時使用 。 預設值:false
。
組態轉換將會針對 *.Release.config
執行,並在 *.<EnvironmentName>.config
上執行 *.config file
。
組態轉換將會在變數替代之前執行。
只有 Windows 平臺才支援 XML 轉換。
enableXmlVariableSubstitution
-
XML 變數替代
輸入別名:XmlVariableSubstitution
。
boolean
。 選擇性。
WebAppKind != linux && WebAppKind != applinux && WebAppKind != "" && Package NotEndsWith .war
時使用 。 預設值:false
。
在組建或發行管線中定義的變數,將會與任何組態檔和 parameters.xml
appSettings
、applicationSettings
和 connectionStrings
區段中的 key
或 name
項目進行比對。 變數替代會在組態轉換之後執行。
注意:如果在發行管線和環境中定義相同的變數,則環境變數將會取代發行管線變數。
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 App Service
Azure App Service 部署工作支援使用 Microsoft Entra 標識符連線至 azure Microsoft Azure,除非有下列三個條件:
- 您在 Windows 代理程式上使用 Web Deploy 套件格式
- 您的代理程式是以舊版的 msdeploy.exe 執行(例如,使用 windows-2019 裝載代理程式映射時)
- Azure App Service 已停用基本身份驗證
如果存在這三個條件,您會收到類似 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.
若要解決此問題,您可以選擇下列選項,依喜好設定順序。
- 更新代理程式映像。 如果您使用裝載的代理程式,請從 windows-2019 移至 windows-2022 (或 windows-latest)。 如果您使用自我載入的代理程式,請在代理程式上安裝 Visual Studio 2022,以取得較新版本的 msdeploy.exe。
- 如果您相依於較舊的代理程式映射,且無法更新管線的代理程式,請考慮分割作業,讓 Azure App Service 部署工作在 windows-2022
上執行(或 windows-latest )。 - 如果這兩個選項都不可能,您可以 為 Azure App Service 啟用基本身份驗證。
需求
要求 | 說明 |
---|---|
管線類型 | YAML、傳統組建、傳統版本 |
執行於 | Agent、DeploymentGroup |
需求 | 沒有 |
功能 | 此工作不符合作業中後續工作的任何需求。 |
命令限制 | 任意 |
Settable 變數 | 任意 |
代理程式版本 | 2.104.1 或更高版本 |
工作類別 | 部署 |