Microsoft Cloud Getting Started Guide: How to Deploy Your First Windows/Linux Virtual Machine in Azure
If you're new to cloud computing, Microsoft's Azure (Microsoft Cloud) is definitely a giant that can't be bypassed. When many people open the Azure portal for the first time, they see the dense menu and professional terms, and their heads are instantly big.
Don't panic, the core of cloud computing is to "borrow someone else's computer". Today's tutorial does not talk about complex theories, we directly get started:
Get your first virtual machine (Virtual Machine, VM) set up and successfully connected in Azure.
Whether you want to deploy Windows or Linux, just read this article.
Core concept: three "front pockets" to avoid the pit"
Before you click any button, you need to know three basic concepts of Azure organization resources. This can help you save a lot of money, but also convenient for future management.
Subscription (Subscription): Your billing account. All the expenses are on the subscription. Newly registered users generally have a free quota.
Resource Group (Resource Group, RG): Think of it as a "folder". We will throw all related things such as virtual machines, networks, hard drives, etc. into the same folder. I don't want it anymore, just delete the folder, and all the contents will disappear cleanly, leaving no hidden tail.
Region: The physical data center location of the virtual machine. The principle is: the closer to you or your users, the better (low latency), or which area is cheaper.
Step 1: Generic Process for Creating Virtual Machines
First, open and log in.
In the prominent search bar above the home page, enter
"Virtual Machine"
(or
Virtual Machines
), click enter, and then click in the upper left corner
Create-> Azure Virtual Machine"
.
Next, you will see a configuration page like filling in a form. Regardless of Windows or Linux, the following basic configurations are the same:
1. Basic information configuration
Subscription: Select your existing subscription (such as a free trial).
Resource group: Click "New" and give a name, such as MyFirstVM-RG.
Virtual machine name: Give your computer a name, such as MyWinServer or MyLinuxBox.
Region: You can choose East Asia (Hong Kong) or Southeast Asia (Singapore).
Availability options: Just start learning and select "No infrastructure redundancy" to save money.
Security Type: Select either Standard or Trusted Boot.
2. Select the operating system (image) and configuration size
In
Image
In the drop-down menu, this is the watershed:
If you want to Windows: Select Windows
Server 2022 Datacenter or Windows 11 Pro.
If you want Linux: Select Ubuntu Server 24.04 LTS or CentOS.
Size:
This is the key to determining how much you spend. If it is a personal test, don't choose the default recommended configuration of several hundred dollars a month. Click "View all sizes" to find one
B series (such as Standard_B1s or Standard_B2s)
. The B series are miniature and entry-level examples. The price is very close to the people (ranging from a few dollars to more than ten dollars per month). It is the most suitable for hand training.
Step 2: Parting ways, Windows vs Linux personalization settings
After selecting the system, the authentication method is very different from the login credentials. Let's talk about it separately.
Option A: Deploy Windows Virtual Machines
Windows configuration is very intuitive, is to set an administrator account password.
Management account: user name: do not use admin or administrator(Azure is not allowed for security), change the name, such as azureuser. Password: Set a complex password (must contain uppercase and lowercase letters, numbers, and special characters). Please be sure to take a small notebook to write down!
Inbound Port Rule: Public Inbound Port: Select Allow Selected Ports ". Select Inbound Port: Check RDP (3389). This is a dedicated port for Windows Remote Desktop. Without it, you won't be able to connect to this computer for a while.
Option B: Deploy a Linux virtual machine
Linux is more recommended to use more secure
SSH Key Pair
Login, not password.
Management account: Authentication type: It is strongly recommended to choose SSH public key. User name: the default azureuser. SSH Key Pair Source: Select Generate New Key Pair ". Key pair name: default, such as MyLinuxBox_key.
Inbound Port Rule: Public Inbound Port: Select Allow Selected Ports ". Select Inbound Port: Check SSH (22). This is a dedicated channel for Linux terminal connections.
Step 3: Check and create
Skip the advanced options such as "disk" and "network" in the middle (the default configuration is completely sufficient for beginners) and click directly at the bottom of the page.
View Create"
.
Azure will do a final check on your configuration. After the verification is passed, the estimated hourly rate will be displayed in the lower right corner.
If it is Linux: After clicking "Create", the browser will pop up a prompt to download the private key (.pem file). Extremely important! Download it quickly and store it in a safe place. If you lose it, you will never get into this Linux again.
1-3.
Minutes, see the "your deployment has been completed" prompt, it means that your cloud computer has been turned on! Click "Go to Resources" to find the line called
Public IP address
The number, copy it down.
Step 4: How to connect to your virtual machine?
The computer is on, how do we control it?
1. Connect Windows virtual machines
On your local Windows computer:
Press the shortcut key Win R, enter mstsc, and press Enter to open the remote desktop connection.
In the "Computer" column, paste the Azure public IP address you just copied, and click Connect.
When the credentials window pops up, click "More options"-> "Use another account".
Enter the user name (such as azureuser) and password you set up in Azure.
The certificate warning pops up directly to the point "Yes". After a few seconds, a familiar Windows desktop will appear in front of you.
2. Connect the Linux virtual machine
If you are using Mac, Linux, or upgraded Windows (with CMD or PowerShell):
Open a terminal (Terminal) or PowerShell.
First, use the command line to modify the permissions of the. pem key file you just downloaded (to prevent SSH from refusing to connect due to too open permissions):Bashchmod 400/path/your key. pem (note: if Windows users use PowerShell, they can skip this permission step or directly use third-party tools such as Putty/Xshell)
Enter the following command to log in (replace IP with your Azure virtual machine IP):Bashssh-I/path/your key. pem azureuser @ your public IP address
The first connection will prompt whether to trust, enter yes and enter.
Seeing the green prompt (shaped like azureuser @ vm-name:~$), congratulations, you have successfully entered the cloud Linux in the flesh!
The ultimate money-saving reminder: remember to "delete" or "stop" when you use it "!
Cloud computing is billed on time. Although you chose a cheap configuration, if you keep it on, the balance in the card will slip away a little bit.
If you're just not using it for a while and want to keep the data: On the Virtual Machines page in the Azure portal, click Stop at the top. Note: You must see that the status changes to "de-allocated" (Deallocated) to actually stop. At this point, the CPU and memory stop billing, but a small amount of hard disk storage space will still deduct a little money.
If you're completely finished and don't want to use it: remember the "resource group" (folder) we built in the first step?
Go to the left menu to find "Resource Groups", click your MyFirstVM-RG, and then click "Delete Resource Group" at the top ". Enter the name of the resource group to confirm, Azure will put all the derived resources including virtual machines, IP addresses and hard disks in one pot. This is the cleanest, most thorough, and will never result in subsequent deductions.
Congratulations! Here, you have completed one of the most classic practices of cloud computing. Next, you can try to install a Web server in it, or run your own automated script to officially start your journey to the cloud.
