Step-by-Step Guide: Creating a Linux Virtual Machine on Microsoft Azure
A virtual machine is a software-based emulation of a physical computer. It runs an operating system (Windows, Linux, etc.) and applications just like a physical computer but relies on virtualization technology to share the physical resources (e.g., CPU, memory, storage) of a host server. In Azure, virtual machines are one of the core compute options, providing complete control over the operating system, installed software, and configurations.
Use Cases for Azure Virtual Machines
Application Hosting: Run applications that require control over the environment or custom configurations.
Testing and Development: Build and test applications in isolated environments.
Data Processing: Run computational or data processing workloads like machine learning, big data analytics, and simulations.
Disaster Recovery: Use VMs as part of a business continuity and disaster recovery plan.
Hybrid Cloud Scenarios: Extend your on-premises infrastructure to Azure using VMs.
Microsoft Azure offers a powerful platform for building virtual machines (VMs) tailored to diverse business requirements. This detailed guide outlines the steps to create a virtual machine in Azure.
Prerequisites
Azure Subscription: If you don’t have an Azure account, sign up to get started.
Access to Azure Portal: Log in to the Azure portal.
Step 1: Select the Virtual Machine Option
Log in to the Azure Portal.
On the Azure Home Page, click Virtual Machine under the available Azure Resources.
Click Create and select Azure Virtual Machine.
Step 2: Configure Basic Settings
Why It’s Important: The basic settings define the core properties of your VM, including its name, location, operating system, and security. These settings determine how the VM fits into your Azure infrastructure.
Subscription: Select the appropriate subscription to link the VM to your Azure billing account. This ensures proper cost tracking.
Resource Group: Choose an existing resource group or create a new one by assigning a meaningful name (e.g., Sudais). Resource groups help manage related Azure resources efficiently.
Virtual Machine Name: Provide a meaningful name for your VM (e.g., Adeniyi) to help identify it within your Azure infrastructure.
Region: Select a region for your VM based on proximity to users to ensure low latency. Note: Some services or VM sizes may not be available in certain regions.
Availability Options: Choose an availability option to ensure fault tolerance and high availability. Options include:
No infrastructure redundancy required: Minimal setup without High Availability or Fault Tolerance. Other options (recommended) for better reliability.
Availability Zone: Specify one or more availability zones if needed for additional redundancy.
Security Type: Select a security type based on your workload needs:
Standard: Default option with standard protections.
Trusted Launch: Enhanced security for sensitive workloads.
Confidential VM: Maximum security with advanced hardware protection.
Image: Choose a pre-configured image for the VM, such as Ubuntu Server 22.04 LTS or CentOS. This image includes the operating system and optional pre-installed software.
Size: Select a VM size that matches your workload requirements. This determines processing power, memory, and storage capacity.
Step 3: Set Authentication and Security Details
Authentication Type: Choose an authentication method for the administrator account:
Username/Password: Traditional authentication.
SSH Public Key: For secure key-based authentication (recommended for this setup).
Username: Create a username for the VM administrator (e.g., Ibrahim).
Key Pair Name: Enter a unique name for the SSH key pair (e.g., Ibrahim2).
Step 4: Configure Disks
OS Disk Size: Specify the size of the operating system (OS) disk in gigabytes (GB). Choose an appropriate size based on your workload needs.
OS Disk Type: Select the disk type for the OS disk:
Standard HDD: Basic performance at a lower cost.
Standard SSD: Improved performance with moderate cost.
Premium SSD: High performance and low latency for critical workloads.
Delete with VM: Choose whether the OS disk should be deleted automatically when the virtual machine is deleted. This helps manage disk costs and avoid retaining unused disks.
Key Management: Enable encryption for the OS disk to protect sensitive data. Choose between:
Platform-managed keys: Managed by Azure.
Customer-managed keys: Provide and manage your own encryption keys.
Enable Ultra Disk Compatibility: Toggle this setting if you require ultra-performance disks for workloads with high IOPS and low latency requirements. This is typically used for advanced databases or heavy transactional workloads.
Data Disks: Add and configure additional data disks as needed:
Specify the size, type, and encryption settings for each data disk.
Attach empty disks or use existing managed disks for storing application data, logs, or other files.
Step 5: Configure Networking Settings
Virtual Network: Choose an existing virtual network or create a new one. The virtual network defines the communication boundary for your VM and other resources.
Subnet: Select or create a subnet within the virtual network. This allows the VM to communicate with other resources in the same network segment.
Public IP: Assign a public IP to enable external access to the VM or create one.
NIC Network Security Group: A Network Security Group (NSG) is automatically associated with your NIC. Use it to control inbound and outbound traffic to and from your VM by defining security rules.
Public Inbound Ports: Configure the inbound ports to allow or restrict access to your VM. You can:
Enable selected ports (e.g., SSH for Linux: port 22).
Block all public inbound traffic for enhanced security.
Select Inbound Ports: Specify the ports you want to open for specific use cases, such as:
SSH (Port 22) for remote management.
Other application-specific ports as needed.
Delete Public IP and NIC When VM Is Deleted: Enable this option to ensure the public IP address and NIC are automatically deleted when the VM is deleted, reducing unnecessary resource usage and costs.
Enable Accelerated Networking: Turn on accelerated networking to improve network throughput and reduce latency. This is particularly useful for high-performance workloads.
Step 6: Finalizing VM Creation and Accessing the Virtual Machine
Review and Create: After reviewing your VM configuration, click on Create again to proceed.
Download Private Key: Click on Download private key to download the SSH private key associated with your virtual machine. This key is crucial for secure SSH access to your VM.
Create Resource: Once the private key is downloaded, click Create resource to begin the VM deployment process.
Deployment in Progress: The deployment will start, and you’ll see the status as Deployment is in Progress. Wait for it to complete.
Access the Resource: After the deployment is finished, click on Go to resource to navigate to your newly created virtual machine.
Connect to the VM: Once inside the VM’s overview page, click the Connect drop-down menu and select Connect to initiate an SSH connection.
Public IP Address: A public IP address will be assigned to the VM, enabling remote access.
Step 7: Download and Save the SSH Key
Navigate to your Download folder in Google Chrome or Firefox.
Click on the downloaded SSH key file (e.g., Ibrahim2.pem) to open it.
Copy the key URL and save it in a text file, for example:
C:/Users/PROGRESSIVE/Downloads/Ibrahim2.pem
.Open Windows PowerShell by searching for it in the start menu and click to open.
Wait for the Windows PowerShell window to open.
Step 8: Connect to Your Linux Virtual Machine Using SSH
Open Windows PowerShell: Launch Windows PowerShell on your computer.
Access Your Private Key: Retrieve your copied private key from the location where it was saved (e.g.,
C:/Users/PROGRESSIVE/Downloads/Ibrahim2.pem
).Username and Public IP Address: Get your Username and Public IP Address from the Microsoft Azure Portal
Run the SSH Command: Enter the following SSH command in PowerShell:
ssh -i C:/Users/PROGRESSIVE/Downloads/Ibrahim2.pem Ibrahim@102.37.20.179
Replace the path to the private key and the username as necessary. The format is:
ssh -i <path_to_private_key> <username>@<Public_IP_address>
.Confirm Connection: When prompted with "Are you sure you want to continue connecting (yes/no/[fingerprint])?", type
yes
and press Enter to confirm the connection.Check Host Name: Once connected, click on the hostname to confirm the identity of your VM.
Access Root: Type
sudo su
to switch to the root user and gain full administrative privileges on the Linux VM.
This step finalizes the connection to your Linux virtual machine. If you require further assistance or have any questions, feel free to reach out to me at 08094894224 or via email at oladosuadeniyi39@gmail.com.