Member-only story

Build Your First Azure VM With Terraform

Rakan Khaled
3 min readJul 29, 2024

Creating an Azure Virtual Machine (VM) using Terraform involves defining your infrastructure as code and using Terraform to provision the resources. Here’s a step-by-step guide to create your first Azure VM using Terraform:

Step 1: Install Terraform

First, ensure you have Terraform installed on your system. You can download and install Terraform from the official Terraform website.

Step 2: Configure Azure CLI

Install the Azure CLI, login, and setup your subscription.

  1. Install Azure CLI: Follow the instructions from the official Azure CLI installation guide.
  2. Login to Azure:
  • az login
  1. Set your subscription (if you have multiple):
  • az account set --subscription "your-subscription-id"

Step 3: Create a Directory for Your Terraform Configuration

Create a directory to hold your Terraform configuration files.

mkdir my-terraform-vm
cd my-terraform-vm

Step 4: Create a main.tf File

--

--

Rakan Khaled
Rakan Khaled

No responses yet