Azure Documentation

Managing Azure Virtual Machines

This section covers essential tasks for managing your Azure Virtual Machines (VMs) throughout their lifecycle, from deployment to ongoing operations.

Starting, Stopping, and Deallocating VMs

You can manage the power state of your VMs to control costs and ensure availability.

You can perform these actions using the Azure portal, Azure CLI, or Azure PowerShell.

Azure CLI Example (Deallocate):

az vm deallocate --resource-group MyResourceGroup --name MyVM

Restarting VMs

A restart operation gracefully shuts down and then restarts the VM. This is useful for applying updates or resolving minor issues.

Like stopping a VM, restarting incurs compute charges while the VM is active.

Azure PowerShell Example:

Restart-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM"

Resizing VMs

You can change the size of a VM to adjust its CPU, memory, and storage performance. This is crucial for optimizing costs and meeting changing workload demands.

Important: To resize a VM, it must be deallocated first. After resizing, you will need to start the VM again.

Note: Ensure that the target VM size is available in the Azure region where your VM is located. Some VM sizes are not universally available across all regions.

Attaching and Detaching Data Disks

Virtual machines rely on OS disks for the operating system and can have additional data disks attached for storing applications and data. You can attach new or existing data disks to your VM and detach them when no longer needed.

Considerations for Data Disks:

Managing VM Extensions

VM extensions are small applications that provide post-deployment configuration and management for Azure VMs. They can be used for tasks like configuration management, monitoring, security, and recovery.

Tip: Regularly review and update VM extensions to ensure they are functioning correctly and are secured against the latest threats.

VM Snapshots and Images

Creating snapshots and custom images is vital for backup, disaster recovery, and deploying consistent VM configurations.

Warning: While snapshots are useful, they are not a substitute for a comprehensive backup strategy. Consider Azure Backup for robust data protection.

Connecting to Your VM

Securely connect to your VMs to manage them interactively.

Azure Bastion provides a more secure and seamless RDP/SSH connection experience directly through the Azure portal without exposing public IP addresses.