Hands-On Lab820 words

Lab: Deploying Azure Virtual Machines and Networking

Describe Azure compute and networking services

Lab: Deploying Azure Virtual Machines and Networking

This hands-on lab introduces the foundational compute and networking services of Microsoft Azure. You will create a Resource Group, configure a Virtual Network (VNET), and deploy a Linux Virtual Machine. This corresponds to the AZ-900 Unit 2 learning outcomes.

[!WARNING] Remember to run the teardown commands at the end of this lab to avoid ongoing charges to your Azure account.

Prerequisites

  • Azure Subscription: An active Azure account (Free Trial or Pay-As-You-Go).
  • Interface:
    • Azure Cloud Shell (recommended for CLI) or local installation of Azure CLI.
    • Azure Portal access via web browser.
  • Estimated Time: 15 minutes.

Learning Objectives

  1. Create and manage an Azure Resource Group to organize cloud assets.
  2. Configure an Azure Virtual Network (VNET) and Subnet.
  3. Deploy an Azure Virtual Machine using the CLI and explore Portal alternatives.
  4. Verify connectivity and resource deployment.

Architecture Overview

The following diagram illustrates the relationship between the resources you will deploy. Note that the Virtual Machine must reside within a Subnet, which resides within a VNET, all contained within a Resource Group.

Loading Diagram...

Network Address Space Visual

Compiling TikZ diagram…
Running TeX engine…
This may take a few seconds

Step-by-Step Instructions

Step 1: Create a Resource Group

Azure resources must be placed in a Resource Group. This serves as a logical container for your lab assets.

bash
az group create --name brainybee-lab-rg --location eastus
Console alternative
  1. Search for
Resource Groups

in the top search bar. 2. Click

+ Create

. 3. Select your subscription, name it

brainybee-lab-rg

, and choose

East US

as the region. 4. Click

Review + Create

, then

Create

.

[!TIP] Choose a region close to your physical location for better latency, though eastus is generally reliable for labs.

Step 2: Create a Virtual Network and Subnet

Networking is the backbone of Azure compute. You must define the address space before deploying a VM.

bash
az network vnet create \ --resource-group brainybee-lab-rg \ --name brainybee-lab-vnet \ --address-prefix 10.0.0.0/16 \ --subnet-name default \ --subnet-prefix 10.0.1.0/24
Console alternative
  1. Search for
Virtual Networks

. 2. Click

+ Create

. 3. Select

brainybee-lab-rg

. 4. Name it

brainybee-lab-vnet

. 5. On the

IP Addresses

tab, ensure the IPv4 address space is

10.0.0.0/16

. 6. Add a subnet named

default

with the range

10.0.1.0/24

. 7. Click

Review + Create

.

Step 3: Create the Virtual Machine

Now we deploy a compute resource (Linux VM) into the networking infrastructure we just built.

bash
az vm create \ --resource-group brainybee-lab-rg \ --name brainybee-lab-vm \ --image Ubuntu2204 \ --admin-username azureuser \ --generate-ssh-keys \ --vnet-name brainybee-lab-vnet \ --subnet default

[!IMPORTANT] The --generate-ssh-keys parameter creates security keys for you if they don't exist. Keep track of where they are saved (usually ~/.ssh).

Console alternative
  1. Search for
Virtual Machines

. 2. Click

+ Create > Azure virtual machine

. 3. Basic Tab: Name:

brainybee-lab-vm

, Image:

Ubuntu 22.04 LTS

, Size:

Standard_B1s

(cheapest). 4. Networking Tab: Ensure

brainybee-lab-vnet

and

default

subnet are selected. 5. Click

Review + Create

.

Checkpoints

After running the commands above, verify the deployment:

  1. CLI Verification: Run the following to see your VM's public IP address.
    bash
    az vm list-ip-addresses --resource-group brainybee-lab-rg --name brainybee-lab-vm --output table
  2. Portal Verification: Navigate to the Azure Portal, open Resource Groups, select brainybee-lab-rg. You should see four resources: Virtual Machine, Network Interface, Public IP, and Virtual Network.
  3. Status Check: Ensure the "Provisioning State" of the VM is Succeeded.

Troubleshooting

Error / IssueLikely CauseFix
Ssh key file... not foundLocal environment lacks SSH keysUse --generate-ssh-keys or create keys manually with ssh-keygen.
LocationNotAvailableRegional capacity limitsTry changing the location to westus2 or northeurope.
ResourceGroupNotFoundTypo in name or Step 1 failedRe-run the az group create command and verify with az group list.

Clean-Up / Teardown

To avoid any costs, delete the entire Resource Group. This will automatically delete the VM, VNET, and all associated disks.

bash
az group delete --name brainybee-lab-rg --no-wait --yes

[!NOTE] The --no-wait flag allows the command to return immediately while Azure processes the deletion in the background.

Concept Review

ServiceTypePrimary Purpose
Resource GroupManagementLogical grouping of related resources.
Virtual NetworkNetworkingIsolated environment for resources to communicate.
SubnetNetworkingA range of IP addresses in the VNET to segment traffic.
Virtual MachineComputeOn-demand, scalable computing resources (IaaS).

Ready to study Microsoft Azure Fundamentals (AZ-900)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free