Secure Azure Networks: Network Security Groups, Application Security Groups, Azure Firewall, Bastion and Service Endpoints

Microsoft Certified Azure Administrator Associate AZ 103 65 min min read Updated: Nov 17, 2026 Intermediate
Secure Azure Networks: Network Security Groups, Application Security Groups, Azure Firewall, Bastion and Service Endpoints
Intermediate Topic 2 of 3

Network Security Groups

  • An NSG is a list of allow and deny rules applied to a subnet or a NIC
  • Rules have: priority (100 to 4096, lowest number first), source, destination, port, protocol and action
  • NSGs are stateful: if inbound is allowed, the reply is allowed automatically
  • If both subnet and NIC have an NSG, both must allow the traffic
Default ruleEffect
AllowVnetInBound (65000)Traffic inside the VNet is allowed
AllowAzureLoadBalancerInBound (65001)Load balancer probes allowed
DenyAllInBound (65500)Everything else inbound is blocked
AllowInternetOutBound (65001)Outbound to internet allowed
bash az network nsg create -g rg-net -n nsg-web az network nsg rule create -g rg-net --nsg-name nsg-web -n allow-https --priority 100 --direction Inbound --access Allow \ --protocol Tcp --destination-port-ranges 443 --source-address-prefixes Internet az network nsg rule create -g rg-net --nsg-name nsg-web -n deny-ssh-internet --priority 200 --direction Inbound --access Deny \ --protocol Tcp --destination-port-ranges 22 --source-address-prefixes Internet az network vnet subnet update -g rg-net --vnet-name vnet-app -n web --network-security-group nsg-web
Service tags Use service tags such as Internet, VirtualNetwork, Storage and AzureLoadBalancer instead of long IP lists.

Application Security Groups (ASG)

Group VMs by role (for example asg-web, asg-db) and write rules using the groups. You do not need to change rules when IPs change.

bash az network asg create -g rg-net -n asg-web az network asg create -g rg-net -n asg-db az network nsg rule create -g rg-net --nsg-name nsg-data -n web-to-db --priority 100 --access Allow --protocol Tcp \ --destination-port-ranges 1433 --source-asgs asg-web --destination-asgs asg-db

Troubleshoot NSG Rules

  • Effective security rules on a NIC show the combined rules
  • IP flow verify in Network Watcher tells which rule allows or denies a packet
  • NSG flow logs record traffic for analysis

Azure Firewall

Rule typeUse
DNATPublish an internal service through the firewall's public IP
Network rulesAllow by IP, port, protocol or service tag
Application rulesAllow by FQDN (for example *.microsoft.com) and HTTP/S
  • A managed, central firewall in a hub VNet. Force traffic through it with a route table (0.0.0.0/0 to firewall IP)
  • SKUs: Basic, Standard, Premium (TLS inspection, IDPS)
  • Use Firewall Policy to manage rules

Azure Bastion

bash az network vnet subnet create -g rg-net --vnet-name vnet-app -n AzureBastionSubnet --address-prefixes 10.20.250.0/26 az network public-ip create -g rg-net -n pip-bastion --sku Standard az network bastion create -g rg-net -n bastion-app --vnet-name vnet-app --public-ip-address pip-bastion --sku Basic
  • Browser-based RDP and SSH over TLS to VMs that have no public IP and no open management ports

Service Endpoints and Private Endpoints

Service endpointPrivate endpoint
HowSubnet gets a route to the service over the Azure backboneA private IP in your subnet for the service
Service addressStill the public IP of the servicePrivate IP via private DNS
On-premises accessNoYes (through VPN or ExpressRoute)
CostFreePer endpoint and data
Best forSimple restriction of PaaS to a subnetStrong isolation, disable public access

Practice

  1. Create an NSG that allows HTTPS and denies SSH from the internet
  2. Use ASGs to allow web to database only
  3. Deploy Bastion and connect to a VM without a public IP
  4. Use IP flow verify to test a rule

Conclusion

Use NSGs and ASGs to filter traffic, Azure Firewall for central control, Bastion for safe admin access and private endpoints to remove public exposure of PaaS services.

Quick Summary: NSG; ASG; troubleshoot; Firewall; Bastion; endpoints.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators