Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019
Note
Starting June 1, 2024, newly created App Service apps can generate a unique default hostname that uses the naming convention <app-name>-<random-hash>.<region>.azurewebsites.net. Existing app names remain unchanged. For example:
Use Azure Pipelines to automatically deploy your web app to Azure App Service on every successful build. Azure Pipelines lets you build, test, and deploy with continuous integration (CI) and continuous delivery (CD) using Azure DevOps.
Sign in to your Azure DevOps organization and navigate to your project.
Go to Pipelines, and then select New Pipeline.
When prompted, select the location of your source code: either Azure Repos Git or GitHub.
You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.
When the list of repositories appears, select your repository.
You might be redirected to GitHub to install the Azure Pipelines app. If so, select Approve & install.
When the Configure tab appears, select ASP.NET Core.
When your new pipeline appears, take a look at the YAML to see what it does. When you're ready, select Save and run.
To get started:
Create a pipeline and select the ASP.NET Core template. This selection automatically adds the tasks required to build the code in the sample repository.
Save the pipeline and queue a build to see it in action.
The ASP.NET Core pipeline template publishes the deployment ZIP file as an Azure artifact for the deployment task later.
azureSubscription: Name of the authorized service connection to your Azure subscription.
appName: Name of your existing app.
package: File path to the package or a folder containing your app service contents. Wildcards are supported.
To get started:
Create a release pipeline by selecting Releases from the left menu and select New pipeline.
Select the Azure App Service deployment template for your stage. This automatically adds the necessary tasks.
Note
If you're deploying a Node.js app to App Service on Windows, select the Deploy Node.js App to Azure App Service template. The only difference between these templates is that Node.js template configures the task to generate a web.config file containing a parameter that starts the iisnode service.
To link this release pipeline to the Azure artifact from the previous step, select Add an artifact > Build.
In Source (build pipeline), select the build pipeline you created in the previous section, then select Add.
Save the release pipeline and create a release to see it in action.
package: the file path to the package or a folder containing your app service contents. Wildcards are supported.
For classic pipelines, it's the easiest to define build and release stages in separate pages (Pipelines and Releases, respectively). In general, you:
In the Pipelines page, build and test your app by using the template of your choice, such as ASP.NET Core, Node.js with Grunt, Maven, or others, and publish an artifact.
In the Release page, use the generic Azure App Service deployment template to deploy the artifact.
There may be templates for specific programming languages to choose from.
By default, your deployment happens to the root application in the Azure Web App. You can deploy to a specific virtual application by using the VirtualApplication property of the Azure App Service deploy (AzureRmWebAppDeployment) task:
YAML
- task:AzureRmWebAppDeployment@4 inputs: VirtualApplication:'<name of virtual application>'
By default, your deployment happens to the root application in the Azure Web App. If you want to deploy to a specific virtual application, enter its name in the Virtual Application property of the Azure App Service deploy task.
appType: (optional) Use webAppLinux to deploy to a Web App on Linux.
appName: the name of your existing app service.
deployToSlotOrASE: Boolean. Deploy to an existing deployment slot or Azure App Service Environment.
resourceGroupName: Name of the resource group. Required if deployToSlotOrASE is true.
slotName: Name of the slot, which defaults to production. Required if deployToSlotOrASE is true.
package: the file path to the package or a folder containing your app service contents. Wildcards are supported.
SourceSlot: Slot sent to production when SwapWithProduction is true.
SwapWithProduction: Boolean. Swap the traffic of source slot with production.
Use the option Deploy to Slot or App Service Environment in the Azure Web App task to specify the slot to deploy to. To swap the slots, use the Azure App Service manage task.
In the release pipeline, assuming you're using the Azure App Service deployment template:
Select the Tasks tab, then select Deploy Azure App Service. This is the AzureRmWebAppDeployment task.
In the dialog, make sure that Connection type is set to Azure Resource Manager.
In the dialog, expand Additional Deployment Options and select Select deployment method. Make sure that Web Deploy is selected as the deployment method.
Save the release pipeline.
Note
With the AzureRmWebAppDeployment@3 and AzureRmWebAppDeployment@4 tasks, you should use the Azure Resource Manager connection type, or AzureRM, when deploying with Web Deploy. It uses publishing profiles for deployment when basic authentication is enabled for your app, but it uses the more secure Entra ID authentication when basic authentication is disabled.
Frequently asked questions
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.
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.
I get the message "Invalid App Service package or folder path provided."
In YAML pipelines, depending on your pipeline, there may be a mismatch between where your built web package is saved and where the deploy task is looking for it. For example, the AzureWebApp task picks up the web package for deployment. For example, the AzureWebApp task looks in $(System.DefaultWorkingDirectory)/**/*.zip. If the web package is deposited elsewhere, modify the value of package.
I get the message "Publish using webdeploy options are supported only when using Windows agent."
This error occurs in the AzureRmWebAppDeployment task when you configure the task to deploy using Web Deploy, but your agent isn't running Windows. Verify that your YAML has something similar to the following code:
yml
pool: vmImage:windows-latest
Web Deploy doesn't work when I disable basic authentication
შემოუერთდით Meetup სერიას, რათა შექმნათ მასშტაბური AI გადაწყვეტილებები რეალურ სამყაროში გამოყენების შემთხვევებზე დაყრდნობით თანამემამულე დეველოპერებთან და ექსპერტებთან.
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.