Deploy to a Linux Virtual Machine
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018
We'll show you how to set up continuous deployment of your app to an nginx web server running on Ubuntu using Azure Pipelines or Team Foundation Server (TFS) 2018. You can use the steps in this quickstart for any app as long as your continuous integration pipeline publishes a web deployment package.
After you commit and push a code change, it is automatically built and then deployed. The results will automatically show up on your site.
Define your CI build pipeline
You'll need a continuous integration (CI) build pipeline that publishes your web application, as well as a deployment script that can be run locally on the Ubuntu server. To set up a CI build pipeline, see:
Make sure you follow the additional steps in that topic for creating a build to deploy to Linux.
You'll need a Linux VM with Nginx web server to deploy the app. The deployment scripts used in the sample repositories have been tested on Ubuntu 16.04, and we recommend you use the same version of Linux VM for this quickstart. If you don't already have a Linux VM with Nginx, create one now in Azure using the steps in this example.
Create a deployment group
Deployment groups in Azure Pipelines make it easier to organize the servers you want to use to host your app. A deployment group is a collection of machines with an Azure Pipelines agent on each of them. Each machine interacts with Azure Pipelines to coordinate deployment of your app.
Open a SSH session to your Linux VM. You can do this using the Cloud Shell button on the menu in the upper-right of the Azure portal.
Initiate the session by typing the following command, substituting the IP address of your VM:
For more information, see SSH into your VM.
Run the following command:
sudo apt-get install -y libunwind8 libcurl3
The libraries this command installs are pre-requisites for installing the build and release agent onto a Ubuntu 16.04 VM. Pre-requisites for other versions of Linux can be found here.
Open the Azure Pipelines web portal, navigate to Azure Pipelines, and choose Deployment groups.
Choose Add Deployment group (or New if you have existing deployment groups).
Enter a name for the group such as myNginx and choose Create.
In the Register machine section, make sure that Ubuntu 16.04+ is selected and that Use a personal access token in the script for authentication is also checked. Choose Copy script to clipboard.
The script you've copied to your clipboard will download and configure an agent on the VM so that it can receive new web deployment packages and apply them to web server.
Back in the SSH session to your VM, paste and run the script.
When you're prompted to configure tags for the agent, press Enter (you don't need any tags).
Wait for the script to finish and display the message Started Azure Pipelines Agent. Type "q" to exit the file editor and return to the shell prompt.
Back in Azure Pipelines or TFS, on the Deployment groups page, open the myNginx deployment group. On the Targets tab, verify that your VM is listed.
Define your CD release pipeline
Your CD release pipeline picks up the artifacts published by your CI build and then deploys them to your nginx servers.
Do one of the following to start creating a release pipeline:
If you've just completed a CI build then, in the build's Summary tab under Deployments, choose Create release followed by Yes. This starts a new release pipeline that's automatically linked to the build pipeline.
Open the Releases tab of Azure Pipelines, open the + drop-down in the list of release pipelines, and choose Create release pipeline.
Choose Start with an Empty job.
If you created your new release pipeline from a build summary, check that the build pipeline and artifact is shown in the Artifacts section on the Pipeline tab. If you created a new release pipeline from the Releases tab, choose the + Add link and select your build artifact.
Choose the Continuous deployment icon in the Artifacts section, check that the continuous deployment trigger is enabled, and add a filter that includes the master branch.
Continuous deployment is not enabled by default when you create a new release pipeline from the Releases tab.
Open the Tasks tab, select the Agent job, and choose Remove to remove this job.
Choose ... next to the Stage 1 deployment pipeline and select Add deployment group job.
For the Deployment Group, select the deployment group you created earlier such as myNginx.
The tasks you add to this job will run on each of the machines in the deployment group you specified.
Choose + next to the Deployment group job and, in the task catalog, search for and add a Bash task.
In the properties of the Bash task, use the Browse button for the Script Path to select the path to the deploy.sh script in the build artifact. For example, when you use the nodejs-sample repository to build your app, the location of the script is
Save the release pipeline.
Create a release to deploy your app
You're now ready to create a release, which means to start the process of running the release pipeline with the artifacts produced by a specific build. This will result in deploying the build.
Choose + Release and select Create a release.
In the Create a new release panel, check that the artifact version you want to use is selected and choose Create.
Choose the release link in the information bar message. For example: "Release Release-1 has been created".
In the pipeline view, choose the status link in the stages of the pipeline to see the logs and agent output.
After the release is complete, navigate to your app and verify its contents.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.