Quickstart: Use an ARM template to create a lab in DevTest Labs

This quickstart uses an Azure Resource Manager (ARM) template to create a lab in Azure DevTest Labs that has one Windows Server 2019 Datacenter virtual machine (VM) in it.

In this quickstart, you take the following actions:

  • Review the ARM template.
  • Deploy the ARM template to create a lab and VM.
  • Verify the deployment.
  • Clean up resources.

Prerequisites

If you don't have an Azure subscription, create a free account before you begin.

Review the template

An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.

DevTest Labs can use ARM templates for many tasks, from creating and provisioning labs to adding users. This quickstart uses the Creates a lab with a claimed VM ARM template from the Azure Quickstart Templates gallery. The template defines the following resource types:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.5.6.12127",
      "templateHash": "12097184829658896385"
    }
  },
  "parameters": {
    "labName": {
      "type": "string",
      "metadata": {
        "description": "The name of the new lab instance to be created"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    },
    "vmName": {
      "type": "string",
      "metadata": {
        "description": "The name of the vm to be created."
      }
    },
    "vmSize": {
      "type": "string",
      "defaultValue": "Standard_D4_v3",
      "metadata": {
        "description": "The size of the vm to be created."
      }
    },
    "userName": {
      "type": "string",
      "metadata": {
        "description": "The username for the local account that will be created on the new vm."
      }
    },
    "password": {
      "type": "secureString",
      "metadata": {
        "description": "The password for the local account that will be created on the new vm."
      }
    }
  },
  "variables": {
    "labSubnetName": "[format('{0}Subnet', variables('labVirtualNetworkName'))]",
    "labVirtualNetworkId": "[resourceId('Microsoft.DevTestLab/labs/virtualnetworks', parameters('labName'), variables('labVirtualNetworkName'))]",
    "labVirtualNetworkName": "[format('Dtl{0}', parameters('labName'))]"
  },
  "resources": [
    {
      "type": "Microsoft.DevTestLab/labs",
      "apiVersion": "2018-09-15",
      "name": "[parameters('labName')]",
      "location": "[parameters('location')]"
    },
    {
      "type": "Microsoft.DevTestLab/labs/virtualnetworks",
      "apiVersion": "2018-09-15",
      "name": "[format('{0}/{1}', parameters('labName'), variables('labVirtualNetworkName'))]",
      "dependsOn": [
        "[resourceId('Microsoft.DevTestLab/labs', parameters('labName'))]"
      ]
    },
    {
      "type": "Microsoft.DevTestLab/labs/virtualmachines",
      "apiVersion": "2018-09-15",
      "name": "[format('{0}/{1}', parameters('labName'), parameters('vmName'))]",
      "location": "[parameters('location')]",
      "properties": {
        "userName": "[parameters('userName')]",
        "password": "[parameters('password')]",
        "labVirtualNetworkId": "[variables('labVirtualNetworkId')]",
        "labSubnetName": "[variables('labSubnetName')]",
        "size": "[parameters('vmSize')]",
        "allowClaim": false,
        "galleryImageReference": {
          "offer": "WindowsServer",
          "publisher": "MicrosoftWindowsServer",
          "sku": "2019-Datacenter",
          "osType": "Windows",
          "version": "latest"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.DevTestLab/labs', parameters('labName'))]",
        "[resourceId('Microsoft.DevTestLab/labs/virtualnetworks', parameters('labName'), variables('labVirtualNetworkName'))]"
      ]
    }
  ],
  "outputs": {
    "labId": {
      "type": "string",
      "value": "[resourceId('Microsoft.DevTestLab/labs', parameters('labName'))]"
    }
  }
}

The Azure Quickstart Templates gallery and Azure Quickstart Templates public GitHub repository have several other DevTest Labs ARM quickstart templates.

The Azure Lab Services Community public GitHub repository also has many DevTest Labs artifacts, environments, PowerShell scripts, and quickstart ARM templates you can use or customize for your needs.

Deploy the template

  1. Select the following Deploy to Azure button to sign in to the Azure portal and open the quickstart ARM template:

    Button to deploy the Resource Manager template to Azure.

  2. On the Creates a lab in Azure DevTest Labs with a claimed VM screen, complete the following items:

    • Resource group: Select an existing resource group from the dropdown list, or create a new resource group so it's easy to clean up later.
    • Region: If you created a new resource group, select a location for the resource group and lab.
    • Lab Name: Enter a name for the new lab.
    • Vm Name: Enter a name for the new VM.
    • User Name: Enter a name for the user who can access the VM.
    • Password: Enter a password for the VM user.
  3. Select Review + create, and when validation passes, select Create.

    Screenshot of the Create a lab page.

  4. During the deployment, you can select the Notifications icon at the top of the screen to see deployment progress on the template Overview page. Deployment, especially creating a VM, takes a while.

Validate the deployment

  1. When the deployment is complete, select Go to resource group from the template Overview page or from Notifications.

    Screenshot that shows deployment complete and the Go to resource group button.

  2. The Resource group page lists the resources in the resource group, including your lab and its dependent resources like virtual networks and VMs. Select the DevTest Lab resource to go to the lab's Overview page.

    Screenshot of resource group overview.

  3. On the lab Overview page, you can see the VM under My virtual machines.

    Screenshot that shows the lab Overview page with the virtual machine.

Note

The deployment also creates a resource group for the VM. The resource group contains VM resources like the IP address, network interface, and disk. The resource group appears in your subscription's Resource groups list with the name <lab name>-<vm name>-<numerical string>.

Clean up resources

When you're done using these lab resources, delete them to avoid further charges. You can't delete a resource group that has a lab in it, so delete the lab first:

  1. On the lab overview page, select Delete from the top menu.

    Screenshot of lab delete button.

  2. On the Are you sure you want to delete it page, enter the lab name, and then select Delete.

    During the deletion, you can select Notifications at the top of your screen to view progress. Deleting the lab takes a while.

You can now delete the resource group that contained the lab, which deletes all resources in the resource group.

  1. Select the resource group that contained the lab from your subscription's Resource groups list.

  2. At the top of the page, select Delete resource group.

  3. On the Are you sure you want to delete "<resource group name>" page, enter the resource group name, and then select Delete.

Next steps

In this quickstart, you created a lab that has a Windows VM. To learn how to connect to and manage lab VMs, see the next tutorial: