Build an Azure virtual machine using an Azure RM template
Azure Pipelines | TFS 2018 | TFS 2017 | TFS 2015
Build and release pipelines are called definitions in TFS 2018 and in older versions. Service connections are called service endpoints in TFS 2018 and in older versions.
In just a few steps, you can provision Azure virtual machines (VMs) using Resource Manager (RM) templates. Managing the pipelines for virtual machines in this way is considered Infrastructure as code and is a good DevOps practice.
For this example, the template for creating the Azure VMs must be checked into a version control repository along with the rest of the application code, and it must be published as part of the build output.
Get set up
Before you can build the solution, you must create an Azure RM template.
Create the template
Follow these steps to create and check-in a new Resource Manager template.
In Visual Studio, choose File | Add | New project and add a new Azure Resource Group project to your solution.
When prompted for an Azure template, select Windows Virtual Machine.
The Windows Virtual Machine template is a simple example of provisioning a single virtual machine in Azure. For provisioning other types of resources, you can either edit the WindowsVirtualMachine.json file, select other templates in the project creation wizard, or download one of the many templates available at https://github.com/Azure/azure-quickstart-templates.
Add a project for your app to the solution. This could be a project for an existing app, or a new project created from the Visual Studio File | Add | New project menu.
Create the build pipeline
Carry out the following steps to publish an artifact with the Resource Manager template files.
Make sure that the template files from the HelloWorldARM project are included in the artifacts published by Build.
Queue a new build and verify that the artifact contains the Templates folder containing the template files WindowsVirtualMachine.json and WindowsVirtualMachine.parameters.json.
Enable continuous integration (CI)
On the Triggers tab, enable continuous integration (CI). This tells the system to queue a build whenever someone on your team commits or checks in new code.
Queue and test the build
Save the build pipeline and queue a new build by selecting the Queue new build command. Once the build is done, click Artifacts and then Explore to see the template files produced by the build. This is the template that your release pipeline will consume to provision an Azure virtual machine.
Provision your virtual machine
After you've run the build, you're ready to create a release pipeline to provision your virtual machine: