Azure Documentation

Managing Azure Virtual Machines

This section covers essential tasks for managing your Azure Virtual Machines (VMs) after they have been deployed. Effective management ensures optimal performance, security, and cost-efficiency.

Starting, Stopping, and Restarting VMs

You can control the lifecycle of your VMs through the Azure portal, Azure CLI, or PowerShell.

  • Start: Powers on a deallocated VM. Useful for starting a VM that has been stopped.
  • Stop: Deallocates the VM, releasing compute resources. This is the recommended way to stop a VM to avoid ongoing charges for compute.
  • Restart: Shuts down and restarts the VM.

Azure CLI Example:

# Start a VM
az vm start --resource-group MyResourceGroup --name MyVM

# Stop a VM
az vm stop --resource-group MyResourceGroup --name MyVM

# Restart a VM
az vm restart --resource-group MyResourceGroup --name MyVM

Resizing Virtual Machines

You can change the size of your VM to meet changing performance requirements or to optimize costs. This operation requires stopping (deallocating) the VM.

Steps:

  1. Navigate to your VM in the Azure portal.
  2. Under "Settings", click "Size".
  3. Select a new VM size from the available options.
  4. Click "Resize".

Connecting to Your VM

Accessing your VM is crucial for configuration and troubleshooting.

  • Windows VMs: Use Remote Desktop Connection (RDP). Ensure the RDP port (3389) is open in your Network Security Group (NSG) and that you have valid credentials.
  • Linux VMs: Use SSH. Ensure the SSH port (22) is open in your NSG and you have the necessary keys or password.

The Azure portal provides direct RDP and SSH connection options for supported configurations.

Monitoring VM Performance

Azure Monitor provides comprehensive insights into your VM's performance and health.

  • Metrics: Track CPU usage, disk I/O, network traffic, and more.
  • Logs: Collect detailed diagnostic information from your VM.
  • Alerts: Configure alerts to notify you when specific performance thresholds are met or when errors occur.

Managing Disks

VM disks are where your operating system, applications, and data reside. You can manage these disks by attaching, detaching, or resizing them.

  • Managed Disks: Recommended for all Azure VMs. They are highly available and durable.
  • OS Disk: The disk containing the operating system.
  • Data Disks: Additional disks attached to the VM for storing application data.

You can manage disks through the Azure portal, CLI, or PowerShell, including resizing and changing disk types (e.g., Standard HDD, Standard SSD, Premium SSD).

Azure Resource Manager (ARM) Templates

For automated and consistent VM deployment and management, consider using ARM templates. These JSON files define the infrastructure for your application.

Learn More About ARM Templates