Quickstart: Create a lab plan using a Bicep file

In this quickstart, you, as the educator, create a lab plan using a Bicep file. For 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.

Prerequisites

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 quickstart 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 Bicep file

  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.

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 steps

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