AzureWebApp@1 - Azure Web App v1 task
This task deploys an Azure Web App for Linux or Windows.
Syntax
# Azure Web App v1
# Deploy an Azure Web App for Linux or Windows.
- task: AzureWebApp@1
inputs:
azureSubscription: # string. Required. Azure subscription.
appType: # 'webApp' | 'webAppLinux'. Required. App type.
appName: # string. Required. App name.
#deployToSlotOrASE: false # boolean. Optional. Use when appType != "". Deploy to Slot or App Service Environment. Default: false.
#resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group.
#slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
#customDeployFolder: # string. Optional. Use when package EndsWith .war. Custom Deploy Folder.
#runtimeStack: # string. Optional. Use when appType = webAppLinux. Runtime stack.
#startUpCommand: # string. Optional. Use when appType = webAppLinux. Startup command.
# Application and Configuration Settings
#customWebConfig: # string. Optional. Use when appType != webAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps.
#appSettings: # string. App settings.
#configurationStrings: # string. Configuration settings.
# Additional Deployment Options
#deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != webAppLinux && appType != "" && package NotEndsWith .war && package NotEndsWith .jar. Deployment method. Default: auto.
# Azure Web App v1
# Deploy an Azure Web App for Linux or Windows.
- task: AzureWebApp@1
inputs:
azureSubscription: # string. Required. Azure subscription.
appType: # 'webApp' | 'webAppLinux'. Required. App type.
appName: # string. Required. App name.
#deployToSlotOrASE: false # boolean. Optional. Use when appType != "". Deploy to Slot or App Service Environment. Default: false.
#resourceGroupName: # string. Required when deployToSlotOrASE = true. Resource group.
#slotName: 'production' # string. Required when deployToSlotOrASE = true. Slot. Default: production.
package: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
#runtimeStack: # string. Optional. Use when appType = webAppLinux. Runtime stack.
#startUpCommand: # string. Optional. Use when appType = webAppLinux. Startup command.
# Application and Configuration Settings
#customWebConfig: # string. Optional. Use when appType != webAppLinux && package NotEndsWith .war. Generate web.config parameters for Python, Node.js, Go and Java apps.
#appSettings: # string. App settings.
#configurationStrings: # string. Configuration settings.
# Additional Deployment Options
#deploymentMethod: 'auto' # 'auto' | 'zipDeploy' | 'runFromPackage'. Required when appType != webAppLinux && appType != "" && package NotEndsWith .war && package NotEndsWith .jar. Deployment method. Default: auto.
Inputs
azureSubscription
- Azure subscription
string
. Required.
Specifies the Azure Resource Manager subscription connection for the deployment.
appType
- App type
string
. Required. Allowed values: webApp
(Web App on Windows), webAppLinux
(Web App on Linux).
Specifies the Azure Web App type.
appName
- App name
string
. Required.
Specifies the name of an existing Azure App Service. Only app services that are based on the selected app type will be listed.
deployToSlotOrASE
- Deploy to Slot or App Service Environment
boolean
. Optional. Use when appType != ""
. Default value: false
.
Selects the option to deploy to an existing deployment slot or an Azure App Service Environment.
For both targets, the task needs a resource group name.
If the deployment target is a slot, the default is the production slot. Any other existing slot name can also be provided.
If the deployment target is an Azure App Service Environment, leave the slot name as ‘production’, and specify the resource group name.
resourceGroupName
- Resource group
string
. Required when deployToSlotOrASE = true
.
The resource group name is required when the deployment target is either a deployment slot or an Azure App Service Environment.
Specifies the Azure resource group that contains the Azure App Service indicated above.
slotName
- Slot
string
. Required when deployToSlotOrASE = true
. Default value: production
.
Specifies an existing slot, excluding the production slot.
package
- Package or folder
string
. Required. Default value: $(System.DefaultWorkingDirectory)/**/*.zip
.
The file path to the package or folder that contains App Service content generated by MSBuild, a compressed zip file, or a war file. Variables ( Build | Release) and wildcards are supported. For example, $(System.DefaultWorkingDirectory)/**/*.zip
or $(System.DefaultWorkingDirectory)/**/*.war
.
customDeployFolder
- Custom Deploy Folder
string
. Optional. Use when package EndsWith .war
.
Specifies the custom folder name you want to deploy to.
If the field is empty, the package is deployed to <appname>.azurewebsites.net/<warpackagename>
.
If ROOT is entered, the package is deployed to <appname>.azurewebsited.net
.
In all other instances, it is deployed to <appname>.azurewebsited.net/<customWarName>
.
runtimeStack
- Runtime stack
string
. Optional. Use when appType = webAppLinux
.
Web App on Linux offers two different options to publish your application: custom image deployment (Web App for Containers) and app deployment with a built-in platform image (Web App on Linux). This parameter is only available when Linux Web App is selected as an app type in the task.
startUpCommand
- Startup command
string
. Optional. Use when appType = webAppLinux
.
Specifies the start up command.
For example:
dotnet run
dotnet filename.dll.
customWebConfig
- Generate web.config parameters for Python, Node.js, Go and Java apps
string
. Optional. Use when appType != webAppLinux && package NotEndsWith .war
.
A standard web.config will be generated and deployed to Azure App Service if the application does not have one. The values in web.config vary based on the application framework, and they can be edited. For example, for the node.js application, web.config will have a startup file and iis_node module values. This edit feature is only for the generated web.config.
appSettings
- App settings
string
.
Specify the web app application settings using the syntax -key value
(for example: -Port 5000
-RequestTimeout 5000
-WEBSITE_TIME_ZONE
). Enclose values that contain spaces in double quotes (for example: "Eastern Standard Time"
).
configurationStrings
- Configuration settings
string
.
Specify the web app configuration settings using the syntax -key value
(for example: -phpVersion 5.6
-linuxFxVersion: node|6.11
). Enclose values that contain spaces in double quotes.
deploymentMethod
- Deployment method
string
. Required when appType != webAppLinux && appType != "" && package NotEndsWith .war && package NotEndsWith .jar
. Allowed values: auto
(Auto-detect), zipDeploy
(Zip Deploy), runFromPackage
(Run From Package). Default value: auto
.
Choose the deployment method for the app. Acceptable values are auto, zipDeploy, and runFromPackage.
Task control options
All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.
Output variables
This task defines the following output variables, which you can consume in downstream steps, jobs, and stages.
AppServiceApplicationUrl
The application URL of the selected Azure App Service.
Remarks
Use this task to deploy web applications to Azure App Service.
Deployment methods
Several deployment methods are available in this task. Auto
is the default option.
To change the package-based deployment option in designer task, expand Additional Deployment Options and enable Select Deployment Method.
Based on the type of Azure App Service and Azure Pipelines agent, the task chooses a suitable deployment technology. The different deployment technologies used by the task are:
- Kudu REST APIs
- Zip Deploy
- RunFromPackage
By default, the task tries to select the appropriate deployment technology given the input package, app service type, and agent OS.
- When the app service type is Web App on Linux App, use Zip Deploy
- If a War file is provided, use War Deploy
- If a Jar file is provided, use Run From Package
- For all others, use Run From Zip (via Zip Deploy)
On a non-Windows agent (for any app service type), the task relies on Kudu REST APIs to deploy the web app.
Kudu REST APIs
Kudu REST APIs work on Windows or Linux automation agents when the target is Web App on Windows, Web App on Linux (built-in source), or Function App. The task uses Kudu to copy files to the Azure App Service.
Zip Deploy
Creates a .zip deployment package of the chosen package or folder. The file contents are then deployed to the wwwroot folder of the function app in Azure App Service. This option overwrites all existing contents in the wwwroot folder. For more information, see Zip deployment for Azure Functions.
RunFromPackage
Creates the same deployment package as Zip Deploy. However, instead of deploying files to the wwwroot folder, the entire package is mounted by the Azure Functions runtime. With this option, files in the wwwroot folder become read-only. For more information, see Run your Azure Functions from a package file.
Error: Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.
The task uses the service principal in the service connection to authenticate with Azure. If the service principal has expired or doesn't have permissions to the App Service, the task fails with this error. Verify the validity of the service principal used and that it's present in the app registration. For more information, see Use role-based access control to manage access to your Azure subscription resources. This blog post also contains more information about using service principal authentication.
SSL error
If you want to use a certificate in App Service, the certificate must be signed by a trusted certificate authority. If your web app gives you certificate validation errors, you're probably using a self-signed certificate. Set a variable named VSTS_ARM_REST_IGNORE_SSL_ERRORS
to the value true
in the build or release pipeline to resolve the error.
A release hangs for long time and then fails
This problem could be the result of insufficient capacity in your App Service plan. To resolve this problem, you can scale up the App Service instance to increase available CPU, RAM, and disk space or try with a different App Service plan.
5xx error codes
If you're seeing a 5xx error, check the status of your Azure service.
Azure Function suddenly stopped working
Azure Functions may suddenly stop working if more than one year has passed since the last deployment. If you deploy with "RunFromPackage" in "deploymentMethod", a SAS with an expiration date of 1 year is generated and set as the value of "WEBSITE_RUN_FROM_PACKAGE" in the application configuration. Azure Functions uses this SAS to reference the package file for function execution, so if the SAS has expired, the function will not be executed. To resolve this issue, deploy again to generate a SAS with an expiration date of one year.
Error: No package found with specified pattern
Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
Error: Publish using zip deploy option is not supported for msBuild package type
Web packages created via the MSBuild task (with default arguments) have a nested folder structure that can be deployed correctly only by Web Deploy. The publish-to-zip deployment option can't be used to deploy those packages. To convert the packaging structure, take these steps:
In the Build solution task, change the MSBuild Arguments to
/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="$(System.DefaultWorkingDirectory)\\WebAppContent"
:Add an Archive task and change the values as follows:
Change Root folder or file to archive to
$(System.DefaultWorkingDirectory)\\WebAppContent
.Clear the Prepend root folder name to archive paths check box:
FAQs
What's the difference between the AzureWebApp
and AzureRmWebAppDeployment
tasks?
The Azure Web App task (AzureWebApp
) is the simplest way to deploy to an Azure Web App. By default, your deployment happens to the root application in the Azure Web App.
The Azure App Service Deploy task (AzureRmWebAppDeployment
) can handle more custom scenarios, such as:
- Modify configuration settings inside web packages and XML parameters files.
- Deploy with Web Deploy, if you're used to the IIS deployment process.
- Deploy to virtual applications.
- Deploy to other app types, like Container apps, Function apps, WebJobs, or API and Mobile apps.
Note
File transforms and variable substitution are also supported by the separate File Transform task for use in Azure Pipelines. You can use the File Transform task to apply file transformations and variable substitutions on any configuration and parameters files.
Web app deployment on Windows is successful but the app is not working
This may be because web.config is not present in your app. You can either add a web.config file to your source or auto-generate one using Application and Configuration Settings.
Click on the task and go to Generate web.config parameters for Python, Node.js, Go and Java apps.
Click on the more button
...
to edit the parameters.Select your application type from the drop down.
Click OK. This will populate the web.config parameters required to generate web.config.
Web app deployment on App Service Environment (ASE) is not working
- Ensure that the Azure DevOps build agent is on the same VNET (subnet can be different) as the Internal Load Balancer (ILB) of ASE. This will enable the agent to pull code from Azure DevOps and deploy to ASE.
- If you are using Azure DevOps, the agent doesn't need to be accessible from the internet but needs only outbound access to connect to Azure DevOps Service.
- If you are using TFS/Azure DevOps Server deployed in a Virtual Network, the agent can be completely isolated.
- The build agent must be configured with the DNS configuration of the Web App it needs to deploy to. The private resources in the Virtual Network don't have entries in Azure DNS, so this needs to be added to the host's file on the agent machine.
- If a self-signed certificate is used for the ASE configuration, the
-allowUntrusted
option needs to be set in the deploy task for MSDeploy. It is also recommended to set the variableVSTS_ARM_REST_IGNORE_SSL_ERRORS
totrue
. If a certificate from a certificate authority is used for ASE configuration, this should not be necessary.
How should I configure my service connection?
This task requires an Azure Resource Manager service connection.
How should I configure web job deployment with Application Insights?
When you're deploying to an App Service, if you have Application Insights configured and you've enabled Remove additional files at destination
, you also need to enable Exclude files from the App_Data folder
. Enabling this option keeps the Application Insights extension in a safe state. This step is required because the Application Insights continuous WebJob is installed into the App_Data folder.
How should I configure my agent if it's behind a proxy while I'm deploying to App Service?
If your self-hosted agent requires a web proxy, you can inform the agent about the proxy during configuration. Doing so allows your agent to connect to Azure Pipelines or Azure DevOps Server through the proxy. Learn more about running a self-hosted agent behind a web proxy.
Examples
Following is an example YAML snippet to deploy web application to the Azure Web App Service running on Windows.
variables:
azureSubscription: Contoso
# To ignore SSL error uncomment the below variable
# VSTS_ARM_REST_IGNORE_SSL_ERRORS: true
steps:
- task: AzureWebApp@1
displayName: Azure Web App Deploy
inputs:
azureSubscription: $(azureSubscription)
appName: samplewebapp
package: $(System.DefaultWorkingDirectory)/**/*.zip
To deploy Web App on Linux, add the appType
parameter and set it to appType: webAppLinux
.
To specify the deployment method as Zip Deploy, add the parameter deploymentMethod: zipDeploy
. Another supported value for this parameter is runFromPackage
.
If not specified, auto
is the default value.
Requirements
Requirement | Description |
---|---|
Pipeline types | YAML, Classic build, Classic release |
Runs on | Agent, DeploymentGroup |
Demands | None |
Capabilities | This task does not satisfy any demands for subsequent tasks in the job. |
Command restrictions | Any |
Settable variables | Any |
Agent version | 2.209.0 or greater |
Task category | Deploy |
Requirement | Description |
---|---|
Pipeline types | YAML, Classic build, Classic release |
Runs on | Agent, DeploymentGroup |
Demands | None |
Capabilities | This task does not satisfy any demands for subsequent tasks in the job. |
Command restrictions | Any |
Settable variables | Any |
Agent version | 2.104.1 or greater |
Task category | Deploy |