Introduction to Azure Virtual Machines
This tutorial guides you through the fundamental concepts and steps involved in creating and managing your first Azure Virtual Machine (VM). Azure VMs provide on-demand, scalable computing resources in the cloud, allowing you to run applications and services without needing to manage physical hardware.
What You Will Learn
- Understanding the benefits of Azure VMs.
- Creating a basic Windows or Linux VM.
- Connecting to your VM.
- Basic VM management tasks.
Prerequisites
Before you begin, you'll need:
- An Azure account. If you don't have one, you can sign up for a free trial.
- Basic understanding of cloud computing concepts.
Step 1: Creating Your First Azure VM
We will use the Azure portal to create a virtual machine. Follow these steps:
Sign in to the Azure Portal
Open your web browser and navigate to https://portal.azure.com/. Sign in with your Azure account credentials.
Navigate to Virtual Machines
In the Azure portal search bar, type "Virtual machines" and select it from the results. Alternatively, click the menu icon in the top left and select "Virtual machines".
Create a Virtual Machine
Click the "+ Create" button and then select "Virtual machine".
Configure Basic Settings
You'll be presented with several tabs for configuration. Start with the "Basics" tab:
- Subscription: Select your Azure subscription.
- Resource group: Create a new one (e.g., `my-vm-rg`) or select an existing one. Resource groups help organize your Azure resources.
- Virtual machine name: Give your VM a unique name (e.g., `my-first-vm`).
- Region: Choose a region geographically close to you or your users for better performance.
- Availability options: For this basic tutorial, you can leave this as default.
- Security type: Standard is suitable for basic testing.
- Image: Select an operating system. For this example, let's choose "Windows Server 2022 Datacenter: Azure Edition" or "Ubuntu Server 22.04 LTS".
- Size: Choose a VM size that fits your needs and budget. For testing, `Standard_B1ms` or `Standard_D2s_v3` are good starting points.
- Administrator account:
- Username: Create a username (e.g., `azureuser`).
- Password: Set a strong password or use SSH public key (for Linux).
- Inbound port rules:
- For Windows, allow RDP (port 3389) to connect remotely.
- For Linux, allow SSH (port 22) to connect remotely.
Configure Disks, Networking, and Management (Optional for Basics)
You can explore the other tabs (Disks, Networking, Management, Advanced, Tags) to customize further. For this tutorial, the default settings on these tabs are usually sufficient.
- Disks: Determines the type and size of storage for your VM.
- Networking: Configures virtual networks, subnets, and public IP addresses.
- Management: Enables monitoring, auto-shutdown, and other management features.
Review and Create
Click on the "Review + create" button. Azure will validate your configuration. Once validation passes, click "Create" to begin the deployment. Deployment typically takes a few minutes.
Step 2: Connecting to Your VM
Once your VM deployment is complete, you can connect to it.
Find Your VM's IP Address
Navigate back to your Virtual Machines list in the Azure portal. Click on your newly created VM. On the VM's overview page, you will find its Public IP address.
Connect via RDP (Windows)
- Open the Remote Desktop Connection application on your local computer.
- Enter the Public IP address of your Azure VM and click "Connect".
- When prompted, enter the username and password you created during VM setup.
Connect via SSH (Linux)
Open a terminal or command prompt on your local computer. Use the following command, replacing <your-username> and <public-ip-address>:
If you are using SSH keys, you may need to specify the path to your private key:
You will be prompted to confirm the connection fingerprint and enter your password or passphrase if your key is protected.
Step 3: Basic VM Management
Azure provides powerful tools for managing your VMs:
Common Management Tasks
- Start/Stop/Restart: You can easily start, stop (deallocate), or restart your VM directly from the Azure portal. Stopping a VM deallocates its resources, saving costs.
- Resize: If your application's demands change, you can resize your VM to a different size with more or fewer resources.
- Monitoring: The "Monitoring" section of your VM provides insights into CPU usage, network traffic, disk I/O, and more.
- Disks: Attach or detach additional data disks for more storage.
- Networking: Manage network security groups (NSGs) to control inbound and outbound traffic.
Conclusion
Congratulations! You have successfully created and connected to your first Azure Virtual Machine. This tutorial covered the basics, but Azure offers a vast array of services for networking, storage, security, and more to build sophisticated cloud solutions.
Next Steps
- Explore different VM sizes and configurations.
- Learn about Azure Virtual Networks and subnets.
- Configure Network Security Groups (NSGs) for enhanced security.
- Investigate Azure Backup and Azure Site Recovery for disaster recovery.
- Deploy applications on your VM.