Azure Series — Part 2: How to Create and Set Up a Virtual Machine (VM) in Microsoft Azure
In Part 1 of this Azure Series, we discussed the basics required to start deploying a web application in Azure.
In this Part 2, we will build a strong foundation for hosting applications by creating and configuring a Virtual Machine (VM) in Microsoft Azure.
A well-configured VM is important because it becomes the environment where your application runs. Whether you’re hosting a web application, APIs, databases, or backend services, the VM setup plays a major role in performance, security, and stability.
At Mass Software Solutions, we believe in continuous learning and knowledge sharing. This article is designed to help beginners and learners understand Azure VM creation and setup step-by-step.
What You Will Learn in This Article
By the end of this guide, you will be able to:
- Create an Azure Virtual Machine (Linux or Windows)
- Configure network settings (VNet, Subnet, Public IP, NSG)
- Allow required ports for access (SSH, HTTP, HTTPS)
- Connect to the VM securely
- Perform initial VM configuration and system setup
- Prepare your VM for application deployment
Prerequisites
Before starting, make sure you have:
- An active Azure Account
- Basic understanding of:
- Virtual Machines
- Networking concepts (VNet, Subnet)
- SSH/RDP (remote access)
1. Login to Azure Portal
Open the Azure Portal and login:
Once logged in, you’ll be on the Azure dashboard where you can manage all your services.
Tip: If you are new, explore the left-side menu — Azure services are grouped by category.
2. Create a Virtual Machine
- In the search bar, type Virtual Machines
- Select Virtual Machines
- Click Create
- Choose Azure Virtual Machine
Before we start creating our VM, it’s important to understand the options Azure provides under the Create menu. Depending on your workload, Azure allows you to launch a single VM, deploy scalable VM groups, use ready-made presets, or explore hybrid and high-volume solutions. Let’s quickly look at what each option means so you can choose the right one with confidence.
1) Virtual machine
This option is the simplest way to get started — create a single Virtual Machine and use it like your own cloud-based computer.
It’s perfect for running web apps, hosting small services, testing configurations, or setting up a development environment.
2) Virtual machine scale set (VMSS)
If you’re planning for high traffic or need multiple VMs running together, VM Scale Sets are the best choice.
They allow you to deploy a group of identical VMs that can automatically scale up or down depending on demand.
This is widely used for production applications where availability, load balancing, and automation matter.
3) Presets
Azure Presets make VM creation faster by giving you pre-built configurations based on common workload needs.
Instead of selecting everything manually, you can start with a recommended setup and adjust it if required.
4) Hybrid, preconfigured, and high volume solutions
This section is designed for enterprise and large-scale deployments where you need consistency and efficiency.
It’s especially useful when working with Azure Arc, bulk VM provisioning, or standardized deployment templates.
3. Configure Basics
Azure will open a VM creation form with multiple tabs.
Step 3. Basics (Subscription & Resource Group)
- Subscription: Select your subscription
- Resource Group:
- Choose an existing Resource Group or
- Create a new one (recommended for project organization)
Step 4. VM Instance Details
Set:
- Virtual machine name: e.g.,
demo1 - Region: choose nearest location for best performance e.g.,
US(East US) - Availability options: keep default unless you need high availability
- For Linux:
Ubuntu Server 22.04 LTS(recommended) - For Windows:
Windows Server 2019/2022 - Size: For practice:
Standard B1sorB2s - For real apps: choose based on workload
When creating a Virtual Machine in Azure, you’ll also choose a Security type. This setting defines how protected your VM will be against threats such as malware, unauthorized boot changes, and advanced attacks. Azure offers three main security options
Which one should you choose?
Standard is a good choice if you are learning Azure, testing setups, or running low-risk workloads where advanced security is not required.
Trusted launch is recommended for most real-world applications, especially production workloads, because it adds stronger protection through Secure Boot and vTPM with minimal extra effort.
Confidential VM should be selected when your workload deals with highly sensitive or regulated data and you need maximum confidentiality — even for data being processed in memory.
- For Linux:
Ubuntu Server 24.04 LTS(recommended) - For Windows:
Windows Server 2019/2022 - Size: For practice:
Standard B1sorB2s - For real apps: choose based on workload
- For Linux:
Ubuntu Server 24.04 LTS(recommended) - For Windows:
Windows Server 2019/2022 - Size: For practice:
Standard B1sorB2s - For real apps: choose based on workload
5. Administrator Account
- Authentication type: Choose how you want to securely access the VM (SSH key is recommended for Linux).
- SSH public key: The most secure method — connect to your VM using a key instead of a password.
- Password: Easier to set up, but less secure and not recommended for production VMs.
- Username: The admin username you will use to log in to the VM.
- SSH public key source: Select whether Azure should generate a new key pair or you want to use an existing one.
- Generate new key pair: Azure creates a fresh SSH key pair during VM creation for secure access.
- SSH Key Type (RSA): Common and widely supported format, often preferred for compatibility.
- SSH Key Type (Ed25519): Modern and secure option with smaller key size and strong security.
- Key pair name: Name assigned to your SSH key pair so you can identify and reuse it later.
- Inbound port rules: Controls which ports are open to the public internet for accessing your VM services.
- Public inbound ports (None): Keeps the VM closed from public access — recommended unless you need SSH/HTTP/HTTPS.
For Linux VM
- Authentication type: SSH public key (recommended)
- Username: e.g.,
azureuser - SSH public key:
- Generate a new key (Azure can generate)
- Or upload your existing SSH key
Why SSH key is recommended?
Because it provides stronger security than password authentication.
For Windows VM
- Create:
- Admin username
- Admin password
6. DISK
The Disks tab is where you configure the storage for your Virtual Machine, including the OS disk and any additional data disks you may want to attach later. Azure automatically creates an OS disk based on the selected image, and you can choose the disk size and performance type depending on your workload.
By default, Azure encrypts the VM disks at rest.
- VM disk encryption: Azure automatically encrypts your managed disks (OS and data disks) at rest by default.
- Encryption at host: Adds extra encryption at the host server level for stronger security (if enabled for your subscription).
- OS disk size: Defines the storage size of the operating system disk (default comes from the selected image).
- OS disk type: Selects the performance tier of the OS disk such as Standard HDD, Standard SSD, or Premium SSD.
- Delete with VM: When enabled, the OS disk will be deleted automatically when the VM is deleted (helps avoid extra storage cost).
- Key management: Controls whether encryption keys are managed by Azure (platform-managed) or by you (customer-managed).
- Enable Ultra Disk compatibility: Allows the VM to attach Ultra Disks for very high-performance workloads (only needed for advanced scenarios).
7. Configure Networking
Networking is critical because it controls how your VM connects to the internet and what traffic is allowed.
The Networking tab is where we define how our Azure Virtual Machine connects to the internet and how it will be accessed securely. In this setup, we used the following configuration to keep the VM reachable for administration while maintaining controlled access.
Network Interface Settings
- Virtual Network (VNet):
Dev-backend-vnet
We selected an existing Virtual Network to keep the VM within a structured network environment. This also helps in future scenarios where multiple services need to communicate securely. - Subnet:
default (10.0.0.0/24)
The VM is placed inside the default subnet so it can receive an internal IP and communicate with other resources in the same network. - Public IP:
(new) demo1-ip
A new Public IP address is created so that we can connect to the VM from our local machine using SSH.
NIC Network Security Group
We selected Basic, which allows Azure to automatically configure a Network Security Group (NSG) with simple inbound rules.
This is a good choice for beginners and lab environments where we need quick setup without complex rule management.
Public inbound ports
We selected Allow selected ports, and allowed only:
SSH (22)
This enables secure remote access to the VM (Linux) using SSH.
⚠️ Note: Allowing inbound ports makes your VM accessible from the public internet. In real production environments, it’s recommended to restrict SSH access to specific trusted IPs.
Cleanup & Performance Options
- Delete public IP and NIC when VM is deleted: Not enabled
Since it’s unchecked, the Public IP and NIC will remain even if the VM is deleted, which can result in extra charges if not cleaned up manually. - Enable accelerated networking: Enabled ✅
This improves network performance by reducing latency and improving throughput, which is beneficial for high-performance workloads.
Load Balancing
For this setup, we kept the Load balancing option as None, since this VM is intended for a single instance use case and does not require traffic distribution across multiple servers.
Best Practice for Networking
For better security, allow only the ports you truly need (for example, keep SSH (22) enabled only for administration). In production environments, avoid opening SSH to the public internet — instead, restrict access to trusted IP addresses or use Azure Bastion for secure remote connectivity. Also, enable cleanup options like Delete public IP and NIC when VM is deleted in test environments to avoid unnecessary resource costs.
Allow Required Ports
Select inbound ports based on what you want to do with your VM.
✅ Common ports:
- 22 → SSH (Linux)
- 3389 → RDP (Windows)
- 80 → HTTP (web app)
- 443 → HTTPS (secure web app)
Recommended for Web Application Deployment:
✅ Allow:
- 22 (SSH)
- 80 (HTTP)
- 443 (HTTPS)
⚠️ Security Note:
Only open ports you actually need. Too many open ports increases risk.
8. Management, Monitoring, Advanced and Tag
At this stage, we don’t need any special customization, so we kept the Management, Monitoring, Advanced and Tag tab settings as default. This is a good approach for beginner setups and lab environments.
9. Review + Create VM
After filling the Basics and Networking configuration:
- Click Review + Create
- Azure validates your selections
- Click Create
- Download key Pair.
Azure will start deployment.
Deployment usually takes 2–5 minutes.
8. Connect to the VM
Once deployment is complete, go to:
Virtual Machines → Your VM
For Linux VM (SSH)
- Click Connect
- Choose SSH
- Copy the SSH command shown, example:
ssh azureadmin@<public-ip>If using a key file:
ssh -i <private-key.pem> azureadmin@<public-ip>Now you are connected to your Linux server.
For Windows VM (RDP)
- Click Connect
- Download RDP file
- Open RDP file and login using credentials
9. Update and Set Up the VM Environment (Linux)
After connecting to a Linux VM, the first thing is to update and upgrade the system packages.
Update VM Packages
Run:
sudo apt update
sudo apt upgrade -yInstall Essential Tools
Install useful tools:
sudo apt install -y curl wget unzip gitThese help in downloading dependencies and managing code deployment.
Install Web Server (Optional: Nginx)
If your application will be accessed through a browser, installing a web server is helpful.
Install Nginx:
sudo apt install -y nginxStart and enable Nginx:
sudo systemctl start nginx
sudo systemctl enable nginxNow check in browser: Site can’t be reached
http://<public-ip>You can see below screens
Now you need to allow http port in network settings
If you visit network settings you can see like below settings
ADD Inbound rule — allow http port
You should see the Nginx default page.
Common Issues and Fixes
SSH Connection Timeout
Check:
- NSG inbound rule allows port 22
- VM is running
- You are using correct IP
- You are using correct SSH key
Cannot Access HTTP (Port 80)
Ensure:
- Port 80 is allowed in NSG
- Nginx/Apache is installed and running
- Firewall inside VM allows port 80
Final Thoughts
Creating and setting up an Azure VM is one of the most essential skills for any cloud learner.
Once your VM is configured properly, you can use it for application deployment, automation, DevOps pipelines, cloud security testing, and more.
At Mass Software Solutions, we believe that sharing practical knowledge helps teams grow stronger and builds better cloud engineering practices across the community.
What’s Next? (Part 3 Preview)
In Part 3 of this Azure Series, we will take the next step by strengthening our VM setup with more secure and practical cloud integrations. We will cover:
— Configuring Managed Identity for the VM to enable secure, passwordless access to Azure services
— Connecting Azure Storage (Blob/File) using identity-based access instead of keys
— Implementing more secure connectivity options and recommended security configurations
— Preparing the VM environment for smoother and safer deployment workflows
This will help us move closer to a real-world, production-ready setup with stronger security and better resource access control.
Contributors
This article was written by Mousumi Bakshi (Senior Solutions Architect)
Stay Connected with Massoftind
Let’s Build the Future Together!
For your Generative AI solutions and project development needs and ongoing updates, technical articles, and insights from our team get in touch with MSS — we’re here to help bring your ideas to life.
👉 Follow us on LinkedIn and Medium for weekly tech insights and practical tips to supercharge your development journey!
