Azure • Compute • 10 Min Read
Deploying Linux VMs: CLI vs Terraform
Automating Virtual Machine creation with SSH keys and network security groups.
1
Quick Deploy via CLI
One command to spin up a Linux VM with automatic SSH key generation.
az vm create \
--resource-group RG-Network-Dev \
--name WebServer01 \
--image Ubuntu2204 \
--admin-username azureuser \
--generate-ssh-keys
2
Infrastructure as Code (Terraform)
Defining the NIC, Public IP, and VM resource for consistent deployments.
resource "azurerm_linux_virtual_machine" "vm" {
name = "devd-vm-prod"
resource_group_name = azurerm_resource_group.main.name
location = "East US"
size = "Standard_B1s"
admin_username = "adminuser"
network_interface_ids = [azurerm_network_interface.nic.id]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "18.04-LTS"
version = "latest"
}
}