Provision an Azure virtual machine using an Azure RM template

Last Update: 6/29/2017

Team Services | TFS 2017 | TFS 2015 | Previous versions: XAML Build, Release

Also check out the new release definition editor.

In just a few steps, you can provision Azure virtual machines (VMs) using Resource Manager (RM) templates. Managing the definitions for virtual machines in this way is considered Infrastructure as code and is a good DevOps practice.

Get set up

Begin with a CI build

Before you begin, you need a CI build that creates your Azure RM template. To set up CI, see:

Create the release definition

Carry out the following steps to deploy the Azure Resource Group.

  1. Open the Releases tab of the Build & Release hub and choose the "+" icon to create a new release definition.

  2. In the Create release definition dialog, select the Empty template and choose Next.

  3. In the next page, select the build definition you created earlier and choose Create. This creates a new release definition with one default environment.

  4. In the new release definition, select + Add tasks and add an Azure Resource Group Deployment task. Optionally edit the name to help identify the task, such as Provision Windows 2012 R2 VM.

  5. Configure the Azure Resource Group Deployment task as follows:

    Azure Resource Group Deployment Deploy: Azure Resource Group Deployment - Deploy files to an Azure Resource Group.

    • Azure Subscription: Select a connection from the list under Available Azure Service Connections or create a more restricted permissions connection to your Azure subscription. For more details, see Azure Resource Manager service endpoint.

    • Action: Create or Update Resource Group.

    • Resource Group: Enter a name for a new resource group, or specify an existing resource group.

    • Template location: The path of the Resource Manager template; for example: $(System.DefaultWorkingDirectory)\ASPNet4.CI\drop\HelloWorldARM\Templates\WindowsVirtualMachine.json.

    • Template Parameters: The path of the Resource Manager template parameters file; for example $(System.DefaultWorkingDirectory)\ASPNet4.CI\drop\HelloWorldARM\Templates\WindowsVirtualMachine.parameters.json.

    • Override Template Parameters: A list of values for the parameters in the template; for example: -adminUsername $(vmuser) -adminPassword (ConvertTo-SecureString -String $(vmpassword) -AsPlainText -Force) -dnsNameForPublicIP $(dns)'. Use the ... button to open the parameters editor dialog.

    • Enable Deployment Prerequisites: Checked.

    • Output - Resource Group: The name of the Resource Group output from the task as a value that can be used as an input to further deployment tasks.

    Checking the Enable Deployment Prerequisites checkbox configures WinRM on the virtual machine and enables execution of remote PowerShell scripts, which may be required to deploy an application. Also notice the use of ConvertTo-SecureString to specify the value for adminPassword. You must do this because adminPassword is defined as a SecureString type in the Resource Manager template file.

  6. If you used variables in the parameters of the Azure Resource Group Deployment task, such as vmuser, vmpassword, and dns, set the values for them in the environment configuration variables. Encrypt the value of vmpassword by selecting the "padlock" icon.

  7. Enter a name for the release definition and save it.

  8. Create a new release, select the latest build, and deploy it to the single environment.


I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.

Help and support