Create virtual machines using an Azure Resource Manager template
When you are creating a virtual machine (VM) in DevTest Labs through the Azure portal, you can view the Azure Resource Manager template before you save the VM. The template can then be used as a basis to create more lab VMs with the same settings.
This article describes Multi-VM vs. single-VM Resource Manager templates and shows you how to view and save a template when creating a VM.
Multi-VM vs. single-VM Resource Manager templates
There are two ways to create VMs in DevTest Labs using a Resource Manager template: provision the Microsoft.DevTestLab/labs/virtualmachines resource or provision the Microsoft.Commpute/virtualmachines resource. Each is used in different scenarios and requires different permissions.
Resource Manager templates that use a Microsoft.DevTestLab/labs/virtualmachines resource type (as declared in the “resource” property in the template) can provision individual lab VMs. Each VM then shows up as a single item in the DevTest Labs virtual machines list:
This type of Resource Manager template can be provisioned through the Azure PowerShell command New-AzureRmResourceGroupDeployment or through the Azure CLI command az group deployment create. It requires administrator permissions, so users who are assigned with a DevTest Labs user role can’t perform the deployment.
Resource Manager templates that use a Microsoft.Compute/virtualmachines resource type can provision multiple VMs as a single environment in the DevTest Labs virtual machines list:
VMs in the same environment can be managed together and share the same lifecycle. Users who are assigned with a DevTest Labs user role can create environments using those templates as long as the administrator has configured the lab that way.
The remainder of this article discusses Resource Manager templates that use Microsoft.DevTestLab/labs/virtualmachines. These are used by lab admins to automate lab VM creation (for example, claimable VMs) or golden image generation (for example, image factory).
Best practices for creating Azure Resource Manager templates offers many guidelines and suggestions to help you create Azure Resource Manager templates that are reliable and easy to use.
View and save a virtual machine's Resource Manager template
- Follow the steps at Create your first VM in a lab to begin creating a virtual machine.
- Enter the required information for your virtual machine and add any artifacts you want for this VM.
At the bottom of the Configure settings window, choose View ARM template.
Copy and save the Resource Manager template to use later to create another virtual machine.
After you have saved the Resource Manager template, you must update the parameters section of the template before you can use it. You can create a parameter.json that customizes just the parameters, outside of the actual Resource Manager template.
The Resource Manager template is now ready to use to create a VM.
- Learn how to Create multi-VM environments with Resource Manager templates.
- Deploy a Resource Manager template to create a VM
- Explore more quickstart Resource Manager templates for DevTest Labs automation from the public DevTest Labs GitHub repo.