Microsoft Azure Disk Configuration: A Guide to Virtual Hard Drives (VHDs)

Learn how to configure and attach virtual hard drives (VHDs) to virtual machines in Microsoft Azure. This guide covers the types of VHDs Azure supports, enabling efficient data storage and management for VM operations using secure and scalable disk configurations.



Microsoft Azure - Disk Configuration

In Azure, disks can be attached to virtual machines (VMs) to store data. These disks are virtual hard drives (VHDs) with a .vhd extension, representing images of physical hard drives. Azure supports different types of VHDs, which are essential for VM operations.

Types of Virtual Hard Disks (VHDs)

  • Operating System VHDs and Data Disks: These are used to store the operating system and additional data, respectively.
  • Image VHDs: Used for creating VM images.

Types of VHDs Based on Extendibility

  • Fixed Size: The size of the VHD remains constant and is supported by Azure.
  • Dynamically Expanding: Expands as data is added, but Azure only supports fixed-size VHDs. To use a dynamically expanding VHD in Azure, it must first be converted to a fixed size. Azure supports a maximum disk size of 1 terabyte.

Virtual Machine and Disks in Azure

When a VM is created in Azure, it is stored in a storage account. If no storage account exists, Azure will create one automatically. If a storage account already exists, you can select it during VM creation.

Steps to Create/Attach a Disk in a Virtual Machine

  1. Go to your VM in the Azure portal.
  2. Select Dashboard from the top menu.
  3. Click Attach diskAttach empty disk at the bottom of the screen.
  4. Fill in the required details in the pop-up screen to attach the disk. It takes a few seconds for the disk to be attached.

Configuring the Disk in a Virtual Machine

  1. Connect to the VM using the .rdp file downloaded to your local machine.
  2. In the VM, right-click the Windows icon at the bottom-left corner and select Disk Management.
  3. A message will indicate that a new disk is available. This is the disk you attached earlier.
  4. The disk will be unallocated initially. Right-click on the unallocated disk (e.g., Disk 2) and select New Simple Volume.
  5. Follow the wizard to set up the disk, including naming the drive and selecting the file system. Ensure Quick Format is selected.
  6. Once the setup is complete, the disk (e.g., F drive) will be ready for use.

Deleting a Disk

  1. Go to the storage account associated with your VM.
  2. Click Containers from the top menu.
  3. Click on vhd.
  4. Locate and select the VHD to delete. Be careful to select the correct VHD, as the list may include VHDs from other VMs.
  5. Delete the selected VHD.

Creating an Image from a Virtual Machine

  1. Go to the management portal.
  2. Select the VM you want to create an image of.
  3. Click Dashboard from the top menu.
  4. Click the Capture icon at the bottom of the window.
  5. Name the image and add a description.
  6. To find the image, select Virtual Machines from the panel, then click Images from the top menu.

Creating an Image from Your Computer

Use the Sysprep tool available in Windows:

  1. Go to C:\Windows\System32\Sysprep.
  2. Run the sysprep application. This creates a VHD file on your computer, representing an image of your machine.

Considerations for Disk Management

  • Disk Naming: With multiple VMs under the same storage account, it can be challenging to identify VHDs. Use the Get-AzureDisk cmdlet in PowerShell to get detailed information about disks associated with each VM.

PowerShell Command:

Get-AzureDisk

This command lists the disks, showing disk names and media links for easier identification.

Azure's disk configuration options provide flexibility in managing data and VM images, supporting efficient and scalable cloud operations. Explore these options to enhance your Azure environment!