Introduction
Hosting a website is one of the most fundamental tasks in cloud computing. Whether you're deploying a simple HTML page, an ASP.NET Core application, or an enterprise-level system, understanding how web servers work is essential.
Microsoft Azure provides multiple hosting options, including Azure Virtual Machines, Azure App Service, Azure Static Web Apps, and container-based services.
In this tutorial, we'll focus on hosting websites using Azure Virtual Machines (VMs).
We'll deploy two websites:
-
Windows Server VM: Host a website using Internet Information Services (IIS).
-
Ubuntu Linux VM: Host a website using Nginx.
Before starting the practical demonstration, we'll understand static and dynamic websites, frontend and backend components, web servers, and application architecture.
What You'll Learn
-
Static vs Dynamic Websites
-
Frontend, Backend, and Database
-
1-Tier, 2-Tier, and 3-Tier Architecture
-
What a Web Server is and how it works
-
IIS vs Nginx
-
Hosting a website on a Windows Azure VM using IIS
-
Hosting a website on an Ubuntu Azure VM using Nginx
-
Configuring Azure Network Security Groups (NSGs)
-
Testing website accessibility using public IP addresses
-
Troubleshooting common hosting issues
-
Azure VM pricing considerations and cleanup
-
Important interview questions and answers
Part 1: Understanding Website Fundamentals
1. What Is a Static Website?
A static website delivers predefined HTML, CSS, JavaScript, and other files to users without requiring server-side content generation for each request.
The web server reads the requested file and sends it to the browser.
How a Static Website Works
User's Browser
|
| HTTP GET /index.html
v
Web Server
(IIS/Nginx)
|
| Locate index.html
v
Static HTML File
|
| HTTP Response
v
User's Browser
|
v
Website Displayed
Example
Consider a personal portfolio website containing:
-
Home
-
About
-
Skills
-
Projects
-
Contact Information
If the pages are predefined HTML files, they can be served directly without server-side processing.
Technologies Used
-
HTML
-
CSS
-
JavaScript
-
Images and static assets
Advantages
-
Fast loading
-
Simple hosting
-
Low infrastructure requirements
-
Easy deployment
-
Reduced server-side attack surface
Disadvantages
-
Server-generated personalization is not available by default.
-
Complex data-driven functionality requires APIs or other services.
-
Frequently changing content can require rebuilding or updating files.
Key Points
-
Static websites serve predefined files.
-
A database is not required for basic static hosting.
-
JavaScript can still make static websites interactive and fetch dynamic information from APIs.
-
Azure Static Web Apps and Azure Storage static website hosting are alternatives to VM hosting.
2. What Is a Dynamic Website?
A dynamic website displays content based on user requests, application logic, database records, or other runtime information.
Examples include:
-
Online banking
-
E-commerce applications
-
Social media platforms
-
Online booking systems
-
Employee management systems
How a Dynamic Website Works
User
|
| Login / View Orders
v
Browser (Frontend)
|
| HTTP Request
v
Backend Application
(ASP.NET Core API)
|
| SQL Query
v
Database
(Azure SQL)
|
| Query Result
v
Backend Application
|
| JSON Response
v
Browser (Frontend)
|
v
Dynamic Content Displayed
Real-Time Example: Online Shopping
When a customer places an order:
-
The frontend sends an HTTP request.
-
The backend authenticates the customer.
-
The backend checks product availability.
-
Payment processing is initiated securely.
-
Order information is stored in the database.
-
The backend returns an order confirmation.
All these operations require application logic.
Technologies Used
|
Component |
Technologies |
|---|---|
|
Frontend |
Angular, React, HTML, CSS, JavaScript |
|
Backend |
ASP.NET Core, Java, Node.js, Python |
|
Database |
SQL Server, Azure SQL, PostgreSQL, MySQL |
|
Web Server |
IIS, Nginx |
|
Hosting |
Azure VM, Azure App Service, Containers |
Key Points
-
Dynamic websites process requests using application logic.
-
They can return HTML, JSON, or other response formats.
-
Dynamic content does not always require a database.
-
Modern single-page applications commonly use REST APIs to retrieve dynamic data.
3. Static vs Dynamic Websites
|
Feature |
Static Website |
Dynamic Website |
|---|---|---|
|
Content |
Predefined files |
Generated or retrieved dynamically |
|
Server-side processing |
Not required for basic pages |
Commonly required |
|
Database |
Optional |
Common but not mandatory |
|
Performance |
Generally fast |
Depends on processing and caching |
|
Development |
Relatively simple |
More complex |
|
Personalization |
Possible through client-side APIs |
Commonly supported |
|
Example |
Documentation website |
Online banking |
|
Azure Hosting |
Static Web Apps, Storage, VM |
App Service, VM, AKS |
Interview Tip: Static and dynamic describe how content is produced, not whether the page contains JavaScript or interactive elements.
Part 2: Frontend, Backend, and Database
4. What Is Frontend?
The frontend is the user-facing part of an application, usually running inside a web browser.
It is responsible for:
-
Displaying information
-
Handling user interactions
-
Validating form inputs
-
Calling backend APIs
-
Rendering API responses
Frontend Technologies
|
Technology |
Purpose |
|---|---|
|
HTML |
Page structure |
|
CSS |
Styling and layout |
|
JavaScript |
Interactivity |
|
TypeScript |
Typed JavaScript development |
|
Angular |
Frontend framework |
|
React |
UI library |
Example
<h1>Welcome to Azure</h1>
<button onclick="alert('Hello Azure!')">
Click Me
</button>
Explanation: The browser displays a heading and button. Clicking the button executes JavaScript without requiring a backend request.
5. What Is Backend?
The backend contains server-side application logic.
It typically handles:
-
Authentication and authorization
-
Business rules
-
Data validation
-
Database operations
-
API endpoints
-
Integration with external services
Example: ASP.NET Core Web API
app.MapGet("/api/products", () =>
{
return Results.Ok(new[]
{
new { Id = 1, Name = "Laptop" },
new { Id = 2, Name = "Mobile" }
});
});
Explanation: When the browser requests /api/products, the ASP.NET Core backend returns product information as JSON.
6. What Is a Database?
A database stores and retrieves application information.
Examples include:
-
Customer records
-
Product details
-
Orders
-
Payment records
-
Application configuration
Common Azure Database Services
|
Database |
Type |
|---|---|
|
Azure SQL Database |
Relational |
|
Azure Database for PostgreSQL |
Relational |
|
Azure Database for MySQL |
Relational |
|
Azure Cosmos DB |
NoSQL / Distributed |
Complete Application Flow
User's Browser
(Angular / React)
|
| HTTPS Request
v
ASP.NET Core API
(Backend)
|
| SQL Query
v
Azure SQL
(Database)
|
| Query Result
v
ASP.NET Core API
|
| JSON Response
v
User's Browser
Key Points
-
Frontend handles presentation and user interaction.
-
Backend executes business logic and controls access to data.
-
Database provides persistent data storage.
-
In a typical secure web application, browsers do not connect directly to the database.
Part 3: Application Architecture
7. What Is 1-Tier Architecture?
In 1-tier architecture, the presentation, business logic, and data storage are contained within a single application environment.
Architecture
User
|
v
+--------------------+
| Single System |
|--------------------|
| Presentation Layer |
| Business Logic |
| Data Storage |
+--------------------+
Example
A standalone desktop application using a local SQLite database.
Advantages
-
Simple development
-
Easy local setup
-
Low infrastructure complexity
Disadvantages
-
Limited independent scalability
-
Potential single point of failure
-
Difficult to distribute responsibilities
Key Point: 1-tier architecture is suitable for small, standalone applications and development environments.
8. What Is 2-Tier Architecture?
In 2-tier architecture, the client communicates directly with a server that provides data or application functionality.
A classic example is a desktop application communicating directly with a database server.
Architecture
Tier 1 - Client
+-------------------+
| Desktop App |
| UI + Business |
| Logic |
+-------------------+
|
| Database Queries
v
Tier 2 - Server
+-------------------+
| Database Server |
| SQL Server |
+-------------------+
Another two-tier deployment may place the application and database together on a server, with a separate client.
Advantages
-
Centralized data management
-
Multiple clients can access the server
-
Simpler than distributed multi-tier architectures
Disadvantages
-
Direct database access can increase security and maintenance concerns.
-
Client updates may be difficult to manage.
-
Scaling can become challenging.
9. What Is 3-Tier Architecture?
3-tier architecture separates an application into three logical tiers:
-
Presentation Tier
-
Application Tier
-
Data Tier
This architecture is widely used in enterprise applications because each tier has a clearly defined responsibility.
Architecture Diagram
Internet
|
v
+----------------------+
| Tier 1: Presentation |
|----------------------|
| Angular / React |
| HTML / CSS / JS |
+----------------------+
|
| HTTPS / REST API
v
+----------------------+
| Tier 2: Application |
|----------------------|
| ASP.NET Core Web API |
| Business Logic |
| Authentication |
+----------------------+
|
| SQL Queries
v
+----------------------+
| Tier 3: Data |
|----------------------|
| Azure SQL Database |
| Persistent Storage |
+----------------------+
Azure Example
Consider an e-commerce application hosted on Azure.
|
Tier |
Azure Service |
Responsibility |
|---|---|---|
|
Presentation |
Azure Static Web Apps |
Hosts Angular frontend |
|
Application |
Azure App Service |
Hosts ASP.NET Core API |
|
Data |
Azure SQL Database |
Stores products and orders |
Advantages
1. Independent Scaling
If API traffic increases, additional backend instances can be deployed without scaling the database unnecessarily.
2. Improved Security
The database can be protected using private networking and restricted access.
3. Maintainability
Frontend, backend, and database responsibilities are separated.
4. Flexibility
Different technologies can be used for different tiers.
5. Deployment Independence
With suitable application design, individual tiers can be deployed separately.
Disadvantages
-
More infrastructure to manage
-
Additional network communication
-
More complex deployment and monitoring
-
Potentially higher operational cost
Important: Three-tier architecture describes logical separation. The tiers do not necessarily require three separate physical servers or VMs. Similarly, three-tier architecture does not automatically guarantee high availability or fault isolation.
10. Comparison: 1-Tier vs 2-Tier vs 3-Tier
|
Feature |
1-Tier |
2-Tier |
3-Tier |
|---|---|---|---|
|
Structure |
Single environment |
Client and server |
Presentation, application, data |
|
Complexity |
Low |
Medium |
Higher |
|
Independent scaling |
Limited |
Limited |
Better |
|
Security boundaries |
Limited |
Moderate |
Stronger when configured correctly |
|
Maintenance |
Simple initially |
Moderate |
Easier separation of responsibilities |
|
Typical usage |
Standalone apps |
Client-server systems |
Enterprise web applications |
Part 4: Understanding Web Servers
11. What Is a Web Server?
A web server is software that accepts HTTP or HTTPS requests and returns website content or forwards requests to an application.
Common web servers include:
-
IIS
-
Nginx
-
Apache HTTP Server
-
Caddy
How a Web Server Works
User's Browser
|
| HTTP Request
| Port 80
v
Azure Public IP
|
v
Network Security Group
|
| Allow TCP 80
v
Azure VM
|
v
IIS / Nginx
|
| Read index.html
v
Website Content
|
| HTTP Response
v
User's Browser
Common HTTP Ports
|
Port |
Protocol |
Purpose |
|---|---|---|
|
80 |
HTTP |
Unencrypted website traffic |
|
443 |
HTTPS |
Encrypted website traffic |
|
22 |
SSH |
Remote Linux administration |
|
3389 |
RDP |
Remote Windows administration |
Key Points
-
IIS and Nginx can serve static files.
-
Both can also act as reverse proxies for backend applications.
-
HTTP typically uses port 80.
-
HTTPS typically uses port 443.
-
Production websites should use HTTPS with valid TLS certificates.
12. IIS vs Nginx
|
Feature |
IIS |
Nginx |
|---|---|---|
|
Full Name |
Internet Information Services |
Nginx |
|
Primary Platform |
Windows |
Linux and other platforms |
|
Configuration |
IIS Manager, PowerShell, configuration files |
Configuration files |
|
Static Websites |
Supported |
Supported |
|
Reverse Proxy |
Supported with appropriate components |
Supported |
|
ASP.NET Core |
Supported |
Supported as reverse proxy |
|
Installation |
Windows Server role |
Package manager |
|
Common Usage |
Windows enterprise applications |
Web hosting, reverse proxy, Linux applications |
Which One Should You Choose?
Choose IIS when:
-
Your infrastructure is Windows-based.
-
Your organization uses Windows Server.
-
You need Windows-integrated hosting features.
Choose Nginx when:
-
Your application runs on Linux.
-
You need a lightweight web server.
-
You want a reverse proxy for ASP.NET Core, Node.js, or other application servers.
Both are suitable for production when configured and maintained correctly.
Part 5: Practical Demo – Host a Website on Azure Windows VM Using IIS
13. Prerequisites
Before starting, ensure you have:
-
An active Azure subscription
-
Permission to create Azure resources
-
Basic knowledge of Azure Portal
-
A Windows computer for RDP access
-
An HTML file for testing
Cost note: Azure resources are not automatically free. Some VM sizes may qualify for introductory free-service allowances on eligible accounts, subject to usage limits and current offer terms. Windows licensing, disks, public IP addresses, and other resources may incur charges. Check the estimated cost before deployment.
14. Create an Azure Resource Group
Step 1: Open Azure Portal
Visit Azure Portal.
Search for Resource groups.
Step 2: Create Resource Group
Click Create and enter:
|
Field |
Value |
|---|---|
|
Subscription |
Your Azure subscription |
|
Resource Group |
|
|
Region |
Your preferred Azure region |
Click Review + create → Create.
15. Create a Windows Virtual Machine
Step 1: Open Virtual Machines
Search for Virtual machines.
Select Create → Azure virtual machine.
Step 2: Configure Basic Settings
|
Field |
Value |
|---|---|
|
Resource Group |
|
|
VM Name |
|
|
Region |
Same preferred region |
|
Image |
Windows Server 2022 Datacenter |
|
Size |
|
|
Username |
|
|
Password |
Strong password |
|
Public Inbound Ports |
Allow selected ports |
|
Inbound Port |
RDP (3389) |
Choose a suitable alternative VM size if B1s is unavailable or unsuitable.
Step 3: Configure Disks
Select a supported disk type such as Standard SSD, based on the workload and cost.
Step 4: Configure Networking
Use or create:
-
Virtual Network
-
Subnet
-
Public IP Address
-
Network Security Group
For security, restrict RDP access to your own public IP address rather than allowing all internet sources.
Step 5: Deploy VM
Click Review + create → Create.
Wait until deployment completes.
16. Open HTTP Port 80 in Azure NSG
Azure Network Security Groups control permitted inbound and outbound network traffic.
Steps
-
Open
windows-web-vm. -
Select Networking.
-
Open the applicable NSG inbound rules.
-
Click Add inbound port rule.
-
Configure the rule.
|
Setting |
Value |
|---|---|
|
Source |
Any |
|
Source Port |
|
|
Destination |
Any |
|
Destination Port |
|
|
Protocol |
TCP |
|
Action |
Allow |
|
Priority |
|
|
Name |
|
Click Add.
Request Flow
Internet User
|
| HTTP Port 80
v
Azure Public IP
|
v
Network Security Group
|
| Rule: Allow TCP 80
v
Windows Azure VM
|
v
IIS Server
|
v
index.html
Key Point: Opening port 80 in the NSG allows network traffic, but the website will only respond when a web server is listening and the guest operating system firewall permits the connection.
17. Connect to Windows VM Using RDP
-
Open the Windows VM in Azure Portal.
-
Select Connect → RDP.
-
Download the RDP file.
-
Open the downloaded file.
-
Enter the configured username and password.
After authentication, the Windows Server desktop will appear.
18. Install IIS on Windows Server
Method 1: Using Server Manager
-
Open Server Manager.
-
Click Add roles and features.
-
Select Role-based or feature-based installation.
-
Select the local server.
-
Enable Web Server (IIS).
-
Accept the required features.
-
Click Install.
Method 2: Using PowerShell
Open PowerShell as Administrator.
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
Verify IIS Installation
Get-Service W3SVC
Expected status:
Status Name DisplayName
------ ---- -----------
Running W3SVC World Wide Web Publishing Service
Open a browser inside the VM and navigate to:
http://localhost
You should see the default IIS welcome page.
19. Host a Static Website in IIS
By default, IIS uses the following physical directory for the Default Web Site:
C:\inetpub\wwwroot
Step 1: Open Website Directory
Open File Explorer and navigate to:
C:\inetpub\wwwroot
Step 2: Create index.html
Create a new file named:
index.html
Step 3: Add HTML Content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Azure IIS Web Server</title>
<style>
body {
font-family: Arial, sans-serif;
background: #0078d4;
color: white;
text-align: center;
padding: 80px 20px;
}
.card {
background: rgba(255,255,255,0.15);
padding: 40px;
border-radius: 12px;
max-width: 650px;
margin: auto;
}
</style>
</head>
<body>
<div class="card">
<h1>Hello from Azure!</h1>
<p>
Website hosted on an Azure Windows VM.
</p>
<p>
Web Server: IIS
</p>
</div>
</body>
</html>
Save the file.
Step 4: Configure Default Document
Open IIS Manager → Sites → Default Web Site → Default Document.
Ensure index.html is enabled and placed before iisstart.htm in the default-document order. Alternatively, remove the default IIS welcome page if it is no longer needed.
Step 5: Test Website
From your local computer, open:
http://<windows-vm-public-ip>
Replace the placeholder with the VM's actual public IP address.
Expected Output
+--------------------------------------+
| |
| Hello from Azure! |
| |
| Website hosted on an Azure Windows VM|
| |
| Web Server: IIS |
| |
+--------------------------------------+
Result: Your static website is now hosted on an Azure Windows VM using IIS.
Part 6: Practical Demo – Host a Website on Ubuntu VM Using Nginx
20. Create an Ubuntu Virtual Machine
Step 1: Open Azure Virtual Machines
Navigate to:
Azure Portal → Virtual machines → Create
Step 2: Configure Basic Settings
|
Field |
Value |
|---|---|
|
Resource Group |
|
|
VM Name |
|
|
Region |
Preferred Azure region |
|
Image |
Ubuntu Server 22.04 LTS |
|
Size |
|
|
Authentication |
SSH Public Key |
|
Username |
|
|
SSH Key Source |
Generate new key pair |
|
Key Name |
|
|
Inbound Port |
SSH (22) |
Restrict SSH access to your own public IP address wherever possible.
Step 3: Deploy
Click Review + create → Create.
Download the generated private key file and store it securely.
ubuntu-web-vm-key.pem
Never upload this private key to a public Git repository.
21. Open HTTP Port 80 for Ubuntu VM
Open:
Ubuntu VM → Networking → NSG Inbound Rules
Create the following rule:
|
Setting |
Value |
|---|---|
|
Source |
Any |
|
Destination Port |
80 |
|
Protocol |
TCP |
|
Action |
Allow |
|
Priority |
310 |
|
Name |
|
Save the rule.
22. Connect to Ubuntu VM Using SSH
Open PowerShell or a terminal.
ssh -i ubuntu-web-vm-key.pem azureuser@<ubuntu-vm-public-ip>
Replace the placeholder with your VM's public IP address.
If you are using macOS or Linux and encounter private-key permission errors:
chmod 400 ubuntu-web-vm-key.pem
On Windows, private-key access permissions are managed through Windows file ACLs.
On the first connection, verify the SSH host fingerprint before accepting it.
23. Install Nginx on Ubuntu
Step 1: Update Package Information
sudo apt update
Step 2: Install Nginx
sudo apt install nginx -y
Step 3: Start and Enable Nginx
sudo systemctl enable --now nginx
Step 4: Verify Nginx Status
sudo systemctl status nginx
Expected status:
nginx.service - A high performance web server
Active: active (running)
Press q to exit the status view.
Step 5: Test Locally
curl http://localhost
The command should return HTML from the default Nginx website.
Step 6: Test Public Access
From your computer, open:
http://<ubuntu-vm-public-ip>
You should see the Nginx welcome page.
24. Host Your HTML Website Using Nginx
Step 1: Navigate to Web Root
cd /var/www/html
Step 2: Check Existing Files
ls -la
On a default Ubuntu Nginx installation, you will commonly find:
index.nginx-debian.html
Step 3: Create index.html
sudo nano /var/www/html/index.html
Step 4: Add HTML Content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Azure Nginx Web Server</title>
<style>
body {
font-family: Arial, sans-serif;
background: #e95420;
color: white;
text-align: center;
padding: 80px 20px;
}
.card {
background: rgba(255,255,255,0.15);
padding: 40px;
border-radius: 12px;
max-width: 650px;
margin: auto;
}
</style>
</head>
<body>
<div class="card">
<h1>Hello from Azure!</h1>
<p>
Website hosted on an Ubuntu Azure VM.
</p>
<p>
Web Server: Nginx
</p>
</div>
</body>
</html>
Save the file:
Ctrl + X
Y
Enter
Step 5: Verify Default Index Configuration
On Ubuntu, Nginx typically looks for index.html before index.nginx-debian.html.
You can inspect the active configuration using:
sudo nginx -T
Step 6: Test Nginx Configuration
sudo nginx -t
Expected result:
syntax is ok
test is successful
For this basic HTML replacement, restarting Nginx is normally unnecessary.
If you modify the Nginx configuration, reload it using:
sudo systemctl reload nginx
Step 7: Access the Website
Open:
http://<ubuntu-vm-public-ip>
Expected Output
+--------------------------------------+
| |
| Hello from Azure! |
| |
| Website hosted on an Ubuntu Azure VM |
| |
| Web Server: Nginx |
| |
+--------------------------------------+
Result: Your static website is now hosted on an Azure Ubuntu VM using Nginx.
Part 7: How Azure Networking Works for Website Hosting
25. Understanding the Complete Network Flow
When a user opens a website hosted on an Azure VM, several components are involved.
Internet User
|
| HTTP Request
| Port 80
v
Azure Public IP
|
v
Azure Virtual Network
|
v
Azure Subnet
|
v
Network Security Group
|
| Allow TCP 80
v
Azure VM Network
Interface
|
v
Operating System
Firewall
|
v
IIS / Nginx
|
v
index.html
|
| HTTP Response
v
User Browser
Components Explained
|
Component |
Purpose |
|---|---|
|
Public IP |
Provides an internet-reachable endpoint |
|
Virtual Network |
Provides the VM's Azure network environment |
|
Subnet |
Defines an IP address range within the VNet |
|
NSG |
Filters permitted network traffic |
|
OS Firewall |
Provides additional host-level filtering |
|
IIS / Nginx |
Handles HTTP requests |
|
HTML File |
Contains the website content |
Key Points
-
A public IP alone does not make a website accessible.
-
NSG rules must allow the required traffic.
-
The operating system firewall must permit the connection.
-
The web server must be running and listening on the correct port.
-
Production websites should generally use HTTPS and restrict administrative access.
Part 8: Troubleshooting Common Website Hosting Problems
26. Website Not Accessible from Browser
Problem 1: Connection Timed Out
Possible Causes
-
Port 80 is blocked by the NSG.
-
Guest operating system firewall blocks traffic.
-
Incorrect public IP address.
-
VM is stopped or deallocated.
-
Web server is not listening on the expected interface.
Solution
Verify the inbound NSG rule:
Protocol: TCP
Port: 80
Action: Allow
Also verify the VM's effective network security rules.
Problem 2: IIS Website Not Loading
Check IIS service status:
Get-Service W3SVC
If stopped:
Start-Service W3SVC
Check the website's status and bindings in IIS Manager.
Problem 3: Nginx Website Not Loading
Check service status:
sudo systemctl status nginx
Restart if required:
sudo systemctl restart nginx
Check configuration:
sudo nginx -t
Check listening ports:
sudo ss -tlnp | grep ':80'
Problem 4: Ubuntu Firewall Blocks HTTP
Check UFW status:
sudo ufw status
If UFW is enabled, allow HTTP:
sudo ufw allow 80/tcp
Problem 5: Default Welcome Page Appears Instead of Custom Website
IIS
Verify the default document order and the physical path of the website.
Nginx
Verify that index.html exists in the configured document root and is included in the index directive.
Troubleshooting Flow
Website Not Loading
|
v
Is VM Running?
/ \
No Yes
| |
Start VM v
Correct Public IP?
/ \
No Yes
| |
Correct IP v
Is Port 80 Allowed?
/ \
No Yes
| |
Update NSG v
Check OS Firewall
|
v
Check IIS / Nginx
|
v
Check Website Files
|
v
Test Website
Part 9: Azure VM Cost Management
27. Stop vs Deallocate vs Delete
Azure VMs consume compute resources while allocated.
Understanding the difference between stopping and deallocating a VM is important for cost management.
|
Operation |
Compute Billing |
Storage Billing |
VM Resources |
|---|---|---|---|
|
Shut down inside OS |
May continue |
Continues |
Retained |
|
Stop / Deallocate in Azure Portal |
Stops when fully deallocated |
Continues |
Retained |
|
Delete VM |
Stops |
Depends on retained resources |
VM removed |
|
Delete Resource Group |
Stops after deletion |
Deleted resources stop billing |
All resources in group removed |
Important Notes
-
Confirm that the VM status is Stopped (deallocated).
-
Managed disks may continue generating charges.
-
Public IP resources may incur charges.
-
Other associated resources may also have separate costs.
28. Clean Up Demo Resources
If the resources were created exclusively for this tutorial, delete the resource group when finished.
Steps
-
Open Azure Portal.
-
Search for Resource groups.
-
Select
web-demo-rg. -
Click Delete resource group.
-
Confirm the resource group name.
-
Complete the deletion.
This removes resources contained in that resource group, including the demo VMs, provided the deletion succeeds.
Warning: Resource group deletion is destructive. Confirm that it contains no resources you need to retain.
Part 10: Real-World Scenario – Hosting an ASP.NET Core Application on Azure
So far, we've hosted static HTML websites.
But how does hosting work for an enterprise ASP.NET Core application?
Consider a system with:
-
Angular frontend
-
ASP.NET Core Web API
-
Azure SQL Database
Production Architecture Example
Internet Users
|
| HTTPS
v
Azure Front Door
|
v
Angular Frontend
(Static Web Apps)
|
| HTTPS API Calls
v
Azure App Service
(ASP.NET Core API)
|
| Private Connection
v
Azure SQL Database
An alternative VM-based architecture is:
Internet Users
|
v
Azure Application Gateway
|
v
Windows / Linux VM
|
+--------+--------+
| |
v v
IIS Nginx
| |
+--------+--------+
|
v
ASP.NET Core API
|
v
Azure SQL DB
These are illustrative deployment options, not mandatory components for every application. The VM-based example shows IIS and Nginx as alternative web-server choices, not as a requirement to run both.
How ASP.NET Core Hosting Works
On Windows
Browser
|
| HTTPS
v
IIS
|
v
ASP.NET Core Module
|
v
ASP.NET Core App
|
v
SQL Database
IIS integrates with ASP.NET Core through the ASP.NET Core Module. Depending on the hosting model, the application may run in-process or behind IIS.
On Linux
Browser
|
| HTTPS
v
Nginx
|
| Reverse Proxy
v
ASP.NET Core Kestrel
|
v
SQL Database
Nginx commonly acts as a reverse proxy, forwarding requests to the ASP.NET Core application running on Kestrel.
Key Point: For simple websites, Azure App Service or Azure Static Web Apps may reduce infrastructure management compared with hosting directly on a VM. Azure VMs remain useful when operating-system control or custom server configuration is required.
Part 11: Important Interview Questions and Answers
The following questions focus specifically on website fundamentals, architecture, IIS, Nginx, Azure VM hosting, and networking.
Group 1: Website Fundamentals
Q1. What is the difference between a static and dynamic website?
A static website serves predefined files without generating content on the server for every request. A dynamic website generates or retrieves content based on application logic, user requests, or data.
Example: HTML documentation website (static) vs online banking application (dynamic).
Q2. What is the difference between frontend and backend?
Frontend handles the user interface and interactions, while backend handles business logic, authentication, APIs, and data processing.
Example: Angular is frontend; ASP.NET Core Web API is backend.
Q3. What is the role of a database in a web application?
A database stores and retrieves persistent application data such as users, orders, and transactions.
Example: Azure SQL Database stores customer and order information.
Q4. Can a static website communicate with a backend API?
Yes. A static website can use JavaScript to call REST APIs and display dynamic information without server-side HTML generation.
Example: An Angular application hosted as static files calling an ASP.NET Core API.
Group 2: Application Architecture
Q5. What is 3-tier architecture?
3-tier architecture separates an application into presentation, application, and data tiers.
This improves separation of concerns and supports independent management and scaling of components.
Q6. What is the difference between 1-tier, 2-tier, and 3-tier architecture?
-
1-Tier: Presentation, logic, and data reside in one environment.
-
2-Tier: Client communicates with a server, often a database server.
-
3-Tier: Presentation, application logic, and data are separated into three logical tiers.
Q7. What are the advantages of 3-tier architecture?
The main advantages are separation of responsibilities, maintainability, scalability, and improved security boundaries.
Each tier can be managed independently when the deployment architecture supports it.
Q8. Does 3-tier architecture require three separate servers?
No. Tiers are logical application boundaries and can share infrastructure.
Separate servers or managed services are commonly used when independent scaling, isolation, or deployment is required.
Group 3: Web Servers – IIS and Nginx
Q9. What is a web server?
A web server is software that processes HTTP/HTTPS requests and serves website content or forwards requests to backend applications.
Examples: IIS, Nginx, Apache.
Q10. What is IIS?
IIS (Internet Information Services) is Microsoft's web server platform for Windows.
It supports static websites, ASP.NET Core hosting, HTTPS, authentication, and other web-server features.
Q11. What is Nginx?
Nginx is a web server commonly used on Linux for static content hosting, reverse proxying, load balancing, and HTTP traffic management.
Q12. What is the difference between IIS and Nginx?
IIS is Windows-based and integrates closely with Microsoft server technologies.
Nginx is widely used on Linux and is commonly configured as a reverse proxy for applications such as ASP.NET Core.
Q13. What is a reverse proxy?
A reverse proxy receives client requests and forwards them to backend application servers.
Example: Nginx receives HTTPS requests and forwards them to an ASP.NET Core application running on Kestrel.
Q14. What is the difference between IIS and Kestrel in ASP.NET Core?
IIS is a Windows web server that can host ASP.NET Core applications through the ASP.NET Core Module.
Kestrel is ASP.NET Core's cross-platform web server and can run directly or behind IIS/Nginx.
Group 4: Azure VM Hosting
Q15. How do you host a website on an Azure Windows VM?
Create a Windows VM, configure networking, install IIS, deploy website files to the configured physical directory, and allow HTTP/HTTPS traffic.
Finally, access the website using its public IP address or configured domain.
Q16. How do you host a website on an Ubuntu Azure VM?
Create an Ubuntu VM, connect using SSH, install Nginx, deploy HTML files to the configured document root, and allow HTTP/HTTPS traffic.
Test the website using its public IP address.
Q17. What is the default website directory in IIS and Nginx?
For common default installations:
IIS:
C:\inetpub\wwwroot
Nginx on Ubuntu:
/var/www/html
These locations can be changed through web-server configuration.
Q18. How do you check whether IIS or Nginx is running?
IIS
Get-Service W3SVC
Nginx
sudo systemctl status nginx
Q19. Why is a public IP required for direct internet access to an Azure VM?
A public IP provides an internet-routable endpoint for reaching the VM directly.
However, a VM can also serve public traffic through Azure Application Gateway, Azure Load Balancer, or another public-facing service without having its own public IP.
Group 5: Azure Networking and Security
Q20. What is an Azure Network Security Group?
An NSG filters inbound and outbound network traffic using rules based on source, destination, protocol, and port.
It helps control network access to Azure resources.
Q21. Why do we open port 80 when hosting a website?
Port 80 is the standard port for HTTP traffic.
The NSG and host firewall must permit the traffic, and the web server must listen on the port.
Q22. What is the difference between ports 80 and 443?
Port 80 is normally used for unencrypted HTTP communication.
Port 443 is normally used for HTTPS, which protects traffic using TLS encryption.
Q23. What is the difference between NSG and Windows/Linux firewall?
An NSG controls traffic at the Azure network level.
The operating system firewall controls traffic inside the VM's operating system.
Both can affect whether a website is reachable.
Q24. Why should SSH and RDP ports not be open to everyone?
Exposing administrative ports publicly increases the risk of unauthorized access and brute-force attacks.
Restrict access using trusted IP addresses, Azure Bastion, VPNs, or other secure administration methods.
Group 6: Troubleshooting and Cost Management
Q25. Your Azure VM is running, but the website is not accessible. What will you check?
Check the public IP, NSG rules, guest firewall, web-server status, listening ports, and website configuration.
Also verify whether the application works locally using localhost.
Q26. What is the difference between stopping and deallocating an Azure VM?
Shutting down the guest OS may leave the VM allocated and compute billing active.
Deallocating releases the compute allocation and stops VM compute charges, although storage and other charges may continue.
Q27. What happens when you delete an Azure resource group?
Azure deletes the resources contained in the group, subject to successful deletion and applicable locks or dependencies.
This is useful for cleaning up temporary environments.
Q28. When should you choose Azure App Service instead of an Azure VM?
Choose App Service when you want managed application hosting with less operating-system maintenance.
Choose Azure VMs when you require greater control over the OS, installed software, or hosting environment.
Part 12: Frequently Asked Questions (FAQ)
Can I host a website on Azure for free?
Eligible Azure subscriptions may include free-service allowances for certain resources. However, VM hosting can incur compute, disk, networking, and other charges. Always check your subscription's current offer and pricing.
Can I host an ASP.NET Core application on Ubuntu using Nginx?
Yes. ASP.NET Core applications run on Linux using Kestrel. Nginx can be configured as a reverse proxy to forward incoming HTTP requests to the application.
Is IIS required to host ASP.NET Core on Windows?
No. ASP.NET Core applications can run directly using Kestrel. IIS is an optional hosting and reverse-proxy integration commonly used in Windows environments.
Can multiple websites run on a single Azure VM?
Yes. IIS and Nginx support hosting multiple websites using different hostnames, ports, or site configurations.
Do I need a domain name to host a website on an Azure VM?
No. You can test a website using the VM's public IP address. A domain name is recommended for a public-facing production website.
Is Azure VM hosting better than Azure App Service?
Neither is universally better. Azure VMs provide more infrastructure control, while App Service reduces server-management responsibilities.
Conclusion
In this tutorial, we explored how websites work and how to host them using Azure Virtual Machines.
We started with static and dynamic websites, understood frontend, backend, and database responsibilities, and compared 1-tier, 2-tier, and 3-tier application architectures.
We then deployed static websites using two different Azure hosting environments:
-
Windows Server + IIS
-
Ubuntu Linux + Nginx
We also covered Azure networking, NSG rules, web-server troubleshooting, security, and cost management.
These concepts provide a foundation for hosting ASP.NET Core applications, Angular frontends, REST APIs, and enterprise systems on Azure.
Key Takeaways
-
Static vs Dynamic: Static websites serve predefined files, while dynamic websites use runtime processing or data to produce content.
-
Frontend, Backend, Database: These components handle presentation, application logic, and persistent storage.
-
3-Tier Architecture: Separates presentation, application, and data responsibilities.
-
IIS: A Windows web server commonly used for enterprise applications.
-
Nginx: A web server widely used for Linux hosting and reverse proxying.
-
Azure NSG: Controls network traffic to Azure resources.
-
Port 80/443: Used for HTTP and HTTPS respectively.
-
Azure VM Cost: Deallocate unused VMs and remove unnecessary resources to control charges.
Next Article: Azure App Service – How to Deploy ASP.NET Core Web Applications Without Managing Virtual Machines
Final SEO Recommendations
For publishing this article on your website:
|
SEO Element |
Recommendation |
|---|---|
|
H1 |
How to Host a Website on Azure VM Using IIS and Nginx – Complete Guide |
|
Meta Title |
Host Website on Azure VM with IIS & Nginx |
|
Meta Description |
Learn static vs dynamic websites, 3-tier architecture, and how to host websites on Azure Windows and Ubuntu VMs using IIS and Nginx. |
|
URL |
|
|
Primary Keyword |
Host website on Azure VM |
|
Article Category |
Azure |
|
Tags |
Azure, Azure VM, IIS, Nginx, Web Hosting, 3-Tier Architecture |
|
Image Alt Text |
Hosting a Website on Azure Virtual Machines Using IIS and Nginx |
|
Internal Links |
Azure Fundamentals, Azure Virtual Machines, Azure Networking, Azure App Service |
|
Structured Data |
|
For a technical tutorial of this length, include a table of contents with anchor links near the beginning. It will make the Windows IIS and Ubuntu Nginx walkthroughs easier to navigate.
The article can also benefit from original screenshots of Azure Portal VM creation, NSG inbound rules, IIS Manager, and Nginx command output. Use actual screenshots from your environment rather than generic Azure screenshots, especially where portal menus have changed.
Tags: Azure Virtual Machines, IIS, Nginx, Web Hosting, 3-Tier Architecture, Windows Server, Ubuntu, Azure Networking