English translation
Log in to Azure
AI Article Decision Snapshot
Turn the lesson into workflow, model, budget, and security checks before choosing tools.
Use this quick snapshot before leaving the article. It keeps the next search tied to practical AI software, model/API, cost, privacy, and implementation questions.
Workflow fit
Identify the real job behind the article: coding, research, document review, support, analytics, content, or internal automation.
Model or tool decision
Decide whether the next step is a software shortlist, an AI tool comparison, an API platform choice, or a model benchmark.
Budget and usage signal
Estimate seats, API calls, prompt volume, retries, review time, and fallback work before assuming the workflow is cheap.
Security and privacy review
Check whether source code, customer data, private documents, prompts, logs, or embeddings will enter the AI workflow.
In the previous article, we introduced how to manage Azure resources using the Azure CLI and PowerShell. In this article, we delve deeper into creating and configuring Virtual Machines (VMs) in Azure. VMs are Azure’s most fundamental compute resource, and we’ll explore how to create and configure them via the Azure Portal, Azure CLI, and PowerShell.
I. Basic Steps for Creating a Virtual Machine
The process of creating a VM consists of the following steps:
- Select an operating system for the VM
- Configure the VM size
- Set up authentication method
- Configure networking and storage options
- Review and create the VM
1. Selecting an Operating System
The first step when creating a VM is selecting an operating system. Azure supports multiple OS options—including Windows and Linux. When using the Azure Portal, you can choose from a wide range of OS images available in the Azure Marketplace.
2. Configuring VM Size
The VM size determines its CPU, memory, and storage capacity. You should select a size appropriate for your workload: for example, a small VM may suffice for development and testing, while production workloads often require larger, more powerful VMs.
3. Setting Up Authentication
During VM creation, you must specify an authentication method. Two common options are:
- Password: Provide a username and password.
- SSH Public Key: For Linux VMs, SSH key-based authentication is recommended and more secure.
4. Configuring Networking
Networking configuration determines how the VM connects to the internet or other Azure resources. Key network settings to consider include:
- Selecting or creating a virtual network (VNet)
- Configuring a subnet
- Assigning a public IP address (if internet access is required)
- Configuring a Network Security Group (NSG)
5. Review and Create
After completing all configurations, review your settings and proceed with VM creation. Once deployment finishes, you can connect to the VM via RDP (for Windows) or SSH (for Linux).
II. Creating a VM Using the Azure Portal
Step-by-Step Example
Here’s how to create a VM through the Azure Portal:
- Sign in to the Azure Portal.
- From the left-hand menu, select “Create a resource” > “Virtual machine”.
- On the “Basics” tab:
- Select your subscription and resource group.
- Enter a name for the VM.
- Choose a region (e.g., East US).
- Select an OS image—e.g., Windows Server 2022 or Ubuntu 20.04 LTS.
- Choose a VM size—for example, Standard_DS1_v2.
- Under Authentication, select SSH public key, then paste your public key.
- On the “Networking” tab:
- Choose an existing VNet or create a new one.
- Configure the public IP address assignment (e.g., “Dynamic” or “Static”).
- Click “Review + create”, verify your settings, then click “Create”.
Sample Code Example (Azure CLI)
Below is an Azure CLI script to create a VM end-to-end:
# Log in to Azure
az login
# Set your subscription
az account set --subscription "your-subscription-id"
# Create a resource group
az group create --name MyResourceGroup --location eastus
# Create a virtual network
az network vnet create --resource-group MyResourceGroup --name MyVnet --subnet-name MySubnet
# Create a public IP address
az network public-ip create --resource-group MyResourceGroup --name MyPublicIP
# Create a network security group
az network nsg create --resource-group MyResourceGroup --name MyNetworkSecurityGroup
# Create a network interface (NIC)
az network nic create \
--resource-group MyResourceGroup \
--name MyNIC \
--vnet-name MyVnet \
--subnet MySubnet \
--public-ip-address MyPublicIP \
--network-security-group MyNetworkSecurityGroup
# Create the VM
az vm create \
--resource-group MyResourceGroup \
--name MyVM \
--nics MyNIC \
--image UbuntuLTS \
--admin-username azureuser \
--ssh-key-value ~/.ssh/id_rsa.pub
III. Creating a VM Using PowerShell
PowerShell offers another powerful, scriptable way to automate Azure resource provisioning. Below is a complete PowerShell example for deploying a VM:
# Log in to Azure
Connect-AzAccount
# Create a resource group
New-AzResourceGroup -Name MyResourceGroup -Location "East US"
# Create a virtual network
$vnet = New-AzVirtualNetwork -Name MyVnet -ResourceGroupName MyResourceGroup -Location "East US" -AddressPrefix "10.0.0.0/16"
$subnet = Add-AzVirtualNetworkSubnetConfig -Name MySubnet -AddressPrefix "10.0.0.0/24" -VirtualNetwork $vnet
$null = Set-AzVirtualNetwork -VirtualNetwork $vnet
# Create a public IP address
$publicIp = New-AzPublicIpAddress -Name MyPublicIP -ResourceGroupName MyResourceGroup -Location "East US" -AllocationMethod Dynamic
# Create a network security group
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName MyResourceGroup -Location "East US" -Name MyNetworkSecurityGroup
# Create a network interface (NIC)
$nic = New-AzNetworkInterface -Name MyNIC -ResourceGroupName MyResourceGroup -Location "East US" -Subnet $subnet -PublicIpAddress $publicIp -NetworkSecurityGroup $nsg
# Create the VM
New-AzVM -ResourceGroupName MyResourceGroup -Name MyVM -Location "East US" -VirtualNetworkName MyVnet -SubnetName MySubnet -SecurityGroupName MyNetworkSecurityGroup -PublicIpAddressName MyPublicIP -ImageName "UbuntuLTS" -Credential (Get-Credential) -NetworkInterfaceName MyNIC
IV. Summary
In this tutorial, we covered the end-to-end process of creating and configuring Virtual Machines in Azure. Whether using the Azure Portal, Azure CLI, or PowerShell, VM provisioning is straightforward and highly customizable. Mastering these techniques empowers you to efficiently deploy and manage compute resources to support your applications and services in the cloud.
In the next article, we’ll explore how to design and configure virtual networks and subnets—enabling better control, segmentation, and optimization of network communication between your Azure VMs. Stay tuned!
Apply This Lesson
Turn this article into AI software, model, API, and security decisions.
English Article FAQ
Use this article as evidence before choosing AI tools
How should I use this AI Tutorials article?
Use it as the implementation or learning layer, then connect the idea to AI software buyer guides, tool comparisons, benchmarks, API choices, and security checks before making a production decision.
Is this English article different from the Chinese original?
The English edition is localized for global AI readers while preserving the original diagrams, screenshots, prompts, code examples, and source context from the Chinese article.
What should I read after Log in to Azure?
Continue with AI Software Buyer Guides, AI Tools Workbench, Best AI Coding Agents, AI Model Benchmarks, OpenAI vs Anthropic API, or LLM Security Tools depending on the decision you need to make.
Can this article alone choose an AI product or model?
No. Treat the article as evidence and context, then validate fit with pricing, privacy requirements, integration effort, benchmark results, workflow tests, and fallback planning.
Continue