Azure Web App task

Azure Pipelines

Use this task to deploy web applications to Azure App service.

Arguments

ParametersDescription
azureSubscription
Azure subscription
(Required) Name of the Azure Resource Manager service connection
appType
App type
(Optional) Web App type
appName
App name
(Required) Name of an existing App Service
deployToSlotOrASE
Deploy to Slot or App Service Environment
(Optional) Select the option to deploy to an existing deployment slot or Azure App Service Environment. For both the targets, the task needs resource group name. In case the deployment target is a slot, by default the deployment is done to the production slot. Any other existing slot name can also be provided. In case the deployment target is an Azure App Service environment, specify the resource group name.
Default value: false
resourceGroupName
Resource group
(Required if deployToSlotOrASE is true) Name of the resource group
slotName
Slot
(Required if deployToSlotOrASE == true) Name of the slot
Default value: production
package
Package or folder
(Required) File path to the package or a folder containing app service contents generated by MSBuild war file or jar file. Variables ( Build | Release), wildcards are supported. For example, $(System.DefaultWorkingDirectory)//.zip or $(System.DefaultWorkingDirectory)//.war
runtimeStack
Runtime stack
(Optional) Web App on Linux offers two different options to publish your application, one is custom image deployment (Web App for Containers) and the other is app deployment with a built-in platform image (Web App on Linux). You will see this parameter only when you select Linux Web App in the app type selection option in the task. [Here](supports a number of Built-in images) is the list of Built-in images support
startUpCommand
Startup command
(Optional; Relevant if appType == webAppLinux) Startup command to be run post deployment
customWebConfig
Generate web.config parameters for Python, Node.js, Go and Java apps
(Optional) 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 can be edited and vary based on the application framework. For example for node.js application, web.config will have startup file and iis_node module values. This edit feature is only for the generated web.config. Learn more
appSettings
App settings
(Optional) Application settings to be entered using the syntax '-key value'. Values containing spaces should be enclosed in double quotes.
Example: -Port 5000 -RequestTimeout 5000 -WEBSITE_TIME_ZONE "Eastern Standard Time"
configurationStrings
Configuration settings
(Optional) Configuration strings to be entered using the syntax '-key value'. Values containing spaces should be enclosed in double quotes.
Example: -phpVersion 5.6 -linuxFxVersion: node|6.11
deploymentMethod
Deployment method
(Required) Deployment method for the app. Acceptable values: auto/zipDeploy/runFromPackage
Default value: auto

Following is an example YAML snippet to deploy web application to the Azure Web App service running on windows.

Example


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 for linux, set the appType parameter to appType: webAppLinux.

To specify the deployment method as Zip Deploy, add the parameter deploymentMethod: zipDeploy. Other supported value for this parameter is runFromPackage. If not mentioned, auto is taken as the default value.

Deployment methods

Several deployment methods are available in this task. Auto is the default option.

To change the deployment option in designer task, expand Additional Deployment Options and enable Select deployment method to choose from additional package-based deployment options.

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 War file is provided, use War Deploy
  • If Jar file is provided, use Run From package
  • For all others, use Run From Zip (via Zip Deploy)

On non-Windows agent (for any App service type), the task relies on Kudu REST APIs to deploy the Web App.

Kudu REST APIs

Works on Windows as well as Linux automation agent when the target is Web App on Windows or 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 and deploys the file contents to the wwwroot folder of the App Service name function app in Azure. 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 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.

Troubleshooting

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 does not have permissions to the App Service, the task fails with the specified error. Verify validity of the service principal used and that it is present in the app registration. For more details, 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

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 may be because there is insufficient capacity on your App Service Plan. To resolve this, 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 are seeing a 5xx error, then check the status of your Azure service.

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 using MSBuild task (with default arguments) have a nested folder structure that can only be deployed correctly by Web Deploy. Publish to zip deploy option can not be used to deploy those packages. To convert the packaging structure, follow the below steps.

  • In 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 Archive Task and change the inputs as follows:

    • Change Root folder or file to archive to $(System.DefaultWorkingDirectory)\WebAppContent Root folder or file to archive

    • Disable Prepend root folder name to archive paths option Prepend root folder name to archive paths

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 the Application and Configuration Settings of the task.

  • Click on the task and go to Generate web.config parameters for Python, Node.js, Go and Java apps.

Generate web.config parameters Dialog

  • Click on the more button Generate web.config parameters for Python, Node.js, Go and Java apps to edit the parameters.

Drop Down Dialog

  • Select your application type from the drop down.
  • Click on OK. This will populate web.config parameters required to generate web.config.

FAQs

How should I configure my service connection?

This task requires an Azure Resource Manager service connection.

How should I configure Web Job Deployment with Azure Application Insights?

When deploying to an App Service with Application Insights configured and you have enabled “Remove additional files at destination”, then you also need to enable “Exclude files from the App_Data folder” in order to keep the app insights extension in a safe state. This is required because App Insights continuous web job gets installed into the App_Data folder.

How should I configure my agent if it is behind a proxy while deploying to App Service?

When your self-hosted agent requires a web proxy, you can inform the agent about the proxy during configuration. This allows your agent to connect to Azure Pipelines or TFS through the proxy. Learn more about running a self-hosted agent behind a web proxy

Open Source

This task is open source on GitHub. Feedback and contributions are welcome.