Quickstart: Create a lab using an ARM template

This quickstart shows you, as the educator or admin, how to use an Azure Resource Manager (ARM) template to create a lab. This quickstart shows you how to create a lab with Windows 11 Pro image. Once a lab is created, an educator configures the template, adds lab users, and publishes the lab. For an overview of Azure Lab Services, see An introduction to Azure Lab Services.

A resource manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Screenshot of the Deploy to Azure button to deploy resources with a template.

Prerequisites

To complete this quick start, make sure that you have:

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.6.18.56646",
      "templateHash": "15693484133732277761"
    }
  },
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location in which the lab resource should be deployed."
      }
    },
    "labName": {
      "type": "string",
      "defaultValue": "[format('lab-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "The name of the lab.  Lab must be unique within the resource group."
      }
    },
    "adminUsername": {
      "type": "string",
      "metadata": {
        "description": "Lab Virtual Machine Administrator User Name"
      }
    },
    "adminPassword": {
      "type": "secureString",
      "metadata": {
        "description": "Lab Virtual Machine Administrator Password"
      }
    },
    "labPlanId": {
      "type": "string",
      "metadata": {
        "description": "Lab Plan Resource Id"
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.LabServices/labs",
      "apiVersion": "2021-11-15-preview",
      "name": "[parameters('labName')]",
      "location": "[parameters('location')]",
      "tags": {},
      "properties": {
        "title": "[parameters('labName')]",
        "labPlanId": "[parameters('labPlanId')]",
        "autoShutdownProfile": {
          "shutdownOnDisconnect": "Enabled",
          "shutdownWhenNotConnected": "Enabled",
          "shutdownOnIdle": "LowUsage",
          "disconnectDelay": "P0D",
          "noConnectDelay": "PT15M",
          "idleDelay": "PT15M"
        },
        "connectionProfile": {
          "webSshAccess": "None",
          "webRdpAccess": "None",
          "clientSshAccess": "None",
          "clientRdpAccess": "Public"
        },
        "virtualMachineProfile": {
          "createOption": "TemplateVM",
          "imageReference": {
            "offer": "windows-11",
            "publisher": "microsoftwindowsdesktop",
            "sku": "win11-21h2-pro",
            "version": "latest"
          },
          "sku": {
            "name": "Classic_Fsv2_2_4GB_128_S_SSD",
            "capacity": 0
          },
          "additionalCapabilities": {
            "installGpuDrivers": "Disabled"
          },
          "usageQuota": "PT10H",
          "useSharedPassword": "Enabled",
          "adminUser": {
            "username": "[parameters('adminUsername')]",
            "password": "[parameters('adminPassword')]"
          }
        },
        "securityProfile": {
          "openAccess": "Disabled"
        }
      }
    }
  ]
}

One Azure resource is defined in the template:

More Azure Lab Services template samples can be found in Azure Quickstart Templates. For more information how to create a lab without a lab plan using automation, see Create Azure LabServices lab template.

Deploy the template

  1. Select the following link to sign in to Azure and open a template. The template creates a lab.

    Screenshot of the Deploy to Azure button to deploy resources with a template.

  2. Optionally, change the name of the lab.

  3. Select the resource group the lab plan you're going to use.

  4. Enter the required values for the template:

    1. adminUser. The name of the user that will be added as an administrator for the lab VM.

    2. adminPassword. The password for the administrator user for the lab VM.

    3. labPlanId. The resource ID for the lab plan to be used. The Id is listed in the Properties page of the lab plan resource in Azure.

      Screenshot of properties page for lab plan in Azure Lab Services with I D property highlighted.

  5. Select Review + create.

  6. Select Create.

The Azure portal is used here to deploy the template. You can also use Azure PowerShell, Azure CLI, or the REST API. To learn other deployment methods, see Deploy resources with ARM templates.

Review deployed resources

You can either use the Azure portal to check the lab, or use the Azure PowerShell script to list the lab resource created.

To use Azure PowerShell, first verify the Az.LabServices module is installed. Then use the Get-AzLabServicesLab cmdlet.

Import-Module Az.LabServices

$lab = Read-Host -Prompt "Enter your lab name"
Get-AzLabServicesLab -Name $lab

Write-Host "Press [ENTER] to continue..."

To verify educators can use the lab, navigate to the Azure Lab Services website: https://labs.azure.com. For more information about managing labs, see View all labs.

Clean up resources

When no longer needed, delete the resource group, which deletes the lab and other resources in the same group.

$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
Remove-AzResourceGroup -Name $resourceGroupName

Write-Host "Press [ENTER] to continue..."

Alternately, an educator may delete a lab from the Azure Lab Services website: https://labs.azure.com. For more information about deleting labs, see Delete a lab.

Next steps

For a step-by-step tutorial that guides you through the process of creating a template, see: