Skip to content

Latest commit

 

History

History
101 lines (65 loc) · 4.39 KB

create-lab-windows-vm-terraform.md

File metadata and controls

101 lines (65 loc) · 4.39 KB
title description ms.topic ms.date ms.custom author ms.author content_well_notification ai-usage
Quickstart: Create a lab in Azure DevTest Labs using Terraform
In this article, you create a Windows virtual machine in a lab within Azure DevTest Labs using Terraform
quickstart
4/14/2023
devx-track-terraform, UpdateFrequency2
TomArcherMsft
tarcher
AI-contribution
ai-assisted

Quickstart: Create a lab in Azure DevTest Labs using Terraform

This article shows how to use Terraform to create a Windows Server 2019 Datacenter virtual machine in a lab within Azure DevTest Labs using Terraform.

In this article, you learn how to:

[!div class="checklist"]

Prerequisites

Implement the Terraform code

  1. Create a directory in which to test and run the sample Terraform code and make it the current directory.

  2. Create a file named main.tf and insert the following code:

    [!code-terraformmaster]

  3. Create a file named outputs.tf and insert the following code:

    [!code-terraformmaster]

  4. Create a file named providers.tf and insert the following code:

    [!code-terraformmaster]

  5. Create a file named variables.tf and insert the following code:

    [!code-terraformmaster]

Initialize Terraform

[!INCLUDE terraform-init.md]

Create a Terraform execution plan

[!INCLUDE terraform-plan.md]

Apply a Terraform execution plan

[!INCLUDE terraform-apply-plan.md]

Verify the results

  1. Get the Azure resource name in which the lab was created.

    resource_group_name=$(terraform output -raw resource_group_name)
  2. Get the lab name.

    lab_name=$(terraform output -raw lab_name)
  3. Run az lab vm list to list the virtual machines for the lab you created in this article.

    az lab vm list --resource-group $resource_group_name \
                   --lab-name $lab_name
    

Clean up resources

[!INCLUDE terraform-plan-destroy.md]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next steps

[!div class="nextstepaction"] Tutorial: Work with lab VMs