You, the admin: let the world reach the web servers on 443 and nothing else
- Network security groups › + Create, name NSG-Web, same region as the VNet.
- NSG-Web › Inbound security rules › + Add: Source Any (or Service tag Internet), destination port 443, protocol TCP, action Allow, priority 100, name Allow-HTTPS.
- Nothing else is needed: the built-in DenyAllInBound at 65500 already blocks the rest. (The built-in AllowVnetInBound at 65000 still lets other VNet traffic in; add a Deny at, say, 4000 if you want to block that too.)
- Attach: NSG-Web › Subnets › + Associate › VNet1 / Web. One NSG can serve many subnets and NICs.
- Verify from a VM: VM › Networking › Effective security rules shows the subnet and NIC lists merged.
Script: az network nsg rule create -g RG-Net --nsg-name NSG-Web -n Allow-HTTPS --priority 100 --destination-port-ranges 443 --access Allow --protocol Tcp
| Rule field | Values |
|---|---|
| Priority | 100 to 4096; lower number is checked first. Built-ins live at 65000+ and cannot be deleted, only out-ranked. |
| Source / destination | Any, an IP or CIDR, a service tag (Internet, VirtualNetwork, AzureLoadBalancer, Storage, Sql, AzureCloud: Microsoft maintains the address lists), or an application security group |
| Port and protocol | Single, range, list; TCP / UDP / ICMP / Any |
| Action | Allow or Deny |
Application security groups are name tags you put on NICs (NIC › Application security groups): WebServers, DbServers. A rule can then say "from WebServers to DbServers port 1433 allow" and keeps working as servers are added or replaced. Create them under Application security groups › + Create; they must be in the same VNet as the NICs.
Routing: overriding Azure's choices
Azure already routes between your subnets, to peered VNets, to the VPN and to the internet. To change that, make a route table (Route tables › + Create), add routes, and associate it with subnets.
| Route field | Meaning |
|---|---|
| Address prefix | Destination, e.g. 0.0.0.0/0 for "everything else" |
| Next hop type | Virtual appliance (your firewall VM's private IP; that VM's NIC needs IP forwarding enabled), Virtual network gateway, Virtual network, Internet, or None (drop) |
| Precedence | Longest matching prefix wins; on a tie, your route beats BGP beats Azure's system route |
Check what a server will actually do under NIC › Effective routes, or ask Network Watcher Next hop for one destination.