0
0
AzureConceptBeginner · 3 min read

What is Subnet in Azure: Simple Explanation and Example

In Azure, a subnet is a smaller network segment within a virtual network (VNet) that helps organize and secure resources. It divides the VNet's IP address range into manageable parts, allowing better control of traffic and resource grouping.
⚙️

How It Works

Think of a virtual network (VNet) in Azure as a large neighborhood. A subnet is like a street within that neighborhood where houses (resources) are grouped together. This grouping helps organize resources logically and controls how they communicate with each other and the outside world.

Each subnet has its own range of IP addresses, carved out from the larger VNet's address space. This is similar to how a street has a range of house numbers. By dividing the network this way, Azure can manage traffic flow, apply security rules, and isolate resources to improve performance and safety.

💻

Example

This example shows how to create a virtual network with a subnet using Azure CLI. It sets up a VNet with an address space and a subnet with its own smaller address range.

bash
az network vnet create --resource-group MyResourceGroup --name MyVNet --address-prefixes 10.0.0.0/16 --subnet-name MySubnet --subnet-prefix 10.0.1.0/24
Output
{ "newVNet": { "addressSpace": { "addressPrefixes": [ "10.0.0.0/16" ] }, "subnets": [ { "addressPrefix": "10.0.1.0/24", "name": "MySubnet" } ], "name": "MyVNet", "resourceGroup": "MyResourceGroup" } }
🎯

When to Use

Use subnets in Azure when you want to organize resources by function, security level, or environment. For example, you might place web servers in one subnet and databases in another to control traffic between them.

Subnets also help apply network security groups (NSGs) to control access and protect resources. They are essential when designing scalable, secure cloud architectures that separate workloads and manage traffic efficiently.

Key Points

  • A subnet divides a virtual network into smaller address ranges.
  • It helps organize and secure Azure resources.
  • Each subnet has its own IP address range within the VNet.
  • Subnets enable applying security rules and controlling traffic.

Key Takeaways

A subnet is a smaller network segment inside an Azure virtual network.
It helps organize resources and control network traffic.
Each subnet has its own IP address range within the VNet.
Use subnets to apply security rules and isolate workloads.
Creating subnets is essential for building secure and scalable Azure networks.