Introduction
This guide walks you through the essential steps required to set up a secure and scalable Azure networking environment for your applications. You'll learn how to create a Virtual Network (VNet), configure subnets, attach Network Security Groups (NSGs), and provision a Public IP address.
Prerequisites
- An active Azure subscription.
- Azure CLI installed (version 2.45+).
- Basic understanding of networking concepts.
Step‑by‑Step Setup
1. Create a Resource Group
az group create --name MyResourceGroup --location eastus
2. Create a Virtual Network
az network vnet create \
--resource-group MyResourceGroup \
--name MyVNet \
--address-prefix 10.0.0.0/16 \
--subnet-name FrontEndSubnet \
--subnet-prefix 10.0.1.0/24
3. Create a Network Security Group
az network nsg create \
--resource-group MyResourceGroup \
--name FrontEndNSG
Allow inbound HTTP and HTTPS traffic:
az network nsg rule create \
--resource-group MyResourceGroup \
--nsg-name FrontEndNSG \
--name AllowHTTP \
--protocol tcp \
--priority 1000 \
--destination-port-range 80 \
--access Allow
az network nsg rule create \
--resource-group MyResourceGroup \
--nsg-name FrontEndNSG \
--name AllowHTTPS \
--protocol tcp \
--priority 1010 \
--destination-port-range 443 \
--access Allow
4. Associate NSG with Subnet
az network vnet subnet update \
--vnet-name MyVNet \
--name FrontEndSubnet \
--resource-group MyResourceGroup \
--network-security-group FrontEndNSG
5. Create a Public IP Address
az network public-ip create \
--resource-group MyResourceGroup \
--name FrontEndPublicIP \
--sku Standard \
--allocation-method Static
6. Deploy a Virtual Machine (example)
az vm create \
--resource-group MyResourceGroup \
--name FrontEndVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys \
--vnet-name MyVNet \
--subnet FrontEndSubnet \
--public-ip-address FrontEndPublicIP \
--nsg FrontEndNSG
Verification
List the configured resources to ensure everything is created correctly:
az network vnet list -g MyResourceGroup -o table