Create a lab plan using a Bicep file or ARM template

In this article, you learn how to create a lab plan using a Bicep file or Azure Resource Manager (ARM) template. For a detailed overview of Azure Lab Services, see An introduction to Azure Lab Services.

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.

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.

Prerequisites

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

Review the Bicep file

The Bicep file used in this article is from Azure Quickstart Templates.

@description('The location in which the lab plan resource should be deployed.')
param location string = resourceGroup().location

@description('The name of the lab plan.  Lab plan must be unique within the resource group.')
param labPlanName string = 'lp-${uniqueString(resourceGroup().id)}'

@description('Regions labs that use this lab plan may be created in.  At least one region must be specified.')
@minLength(1)
param labCreationAllowedRegions array = [
  resourceGroup().location
]

resource labPlanResource 'Microsoft.LabServices/labPlans@2021-11-15-preview' = {
  name: labPlanName
  location: location
  tags: {}
  properties: {
    allowedRegions: labCreationAllowedRegions
    defaultAutoShutdownProfile: {
      shutdownOnIdle: 'LowUsage'
      idleDelay: 'PT15M'
      shutdownOnDisconnect: 'Enabled'
      disconnectDelay: 'PT0S'
      shutdownWhenNotConnected: 'Enabled'
      noConnectDelay: 'PT15M'
    }
  }
}

Deploy the resources

  1. Save the Bicep file as main.bicep to your local computer.

  2. Deploy the Bicep file using either Azure CLI or Azure PowerShell.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters adminUsername=<admin-username>
    

Note

Replace <admin-username> with a unique username. You'll also be prompted to enter adminPassword. The minimum password length is 12 characters.

When the deployment finishes, you should see a messaged indicating the deployment succeeded.

Review deployed resources

Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.

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

az resource list --resource-group exampleRG

Clean up resources

When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the VM and all of the resources in the resource group.

az group delete --name exampleRG

Next step

In this article, you deployed a simple virtual machine using a Bicep file or ARM template. To learn more about Azure virtual machines, continue to the tutorial for Linux VMs.