Azure NSG Practice: Allowed or Denied?

Unlimited Azure NSG practice for the AZ-104 and AZ-700. Each problem gives one flow to or from a VM and the rules of its subnet NSG and NIC NSG: decide if the traffic is allowed, then pick the rule that decides it. A wrong answer names the slip, such as stopping at the subnet NSG when the NIC NSG still has to allow the flow.

Answer to see the working.

Names and addresses are invented. VM1 is in Subnet1. Both NSGs apply to it: one is associated with the subnet, the other with its network interface. Port is the destination port, and the source port is Any in every rule.

Azure exam prep

The AZ-104 study guide lists "Evaluate effective security rules in NSGs", and the AZ-700 study guide lists NSG inbound and outbound security rules. Start with the free real exam questions, then get the full pack.

Microsoft AZ-104606 real exam questions · US$39
Free: 144 questionsGet the full pack
Microsoft AZ-700387 real exam questions · US$39
Free: 47 questionsGet the full pack

Azure NSG rules FAQ

Which NSG is processed first, the subnet NSG or the NIC NSG?

For inbound traffic Azure processes the NSG associated with the subnet first, then the NSG associated with the network interface. For outbound traffic it is the other way round: the NIC NSG first, then the subnet NSG. The same order applies to traffic inside one subnet.

Does traffic have to be allowed by both NSGs?

Yes. In the Microsoft Learn example, to permit port 80 to the VM both the subnet NSG and the NIC NSG must include a rule that allows port 80 from the internet. If the first NSG denies the flow, the second NSG does not evaluate it at all.

How does NSG rule priority work?

A custom rule has a priority between 100 and 4096. Lower numbers are processed before higher numbers, and once traffic matches a rule, processing stops. You cannot create two rules with the same priority and direction in one NSG.

What are the default NSG rules?

Inbound: AllowVNetInBound (65000), AllowAzureLoadBalancerInBound (65001) and DenyAllInbound (65500). Outbound: AllowVnetOutBound (65000), AllowInternetOutBound (65001) and DenyAllOutBound (65500). You cannot remove them, but a custom rule overrides them because it has a lower number.

Why is traffic from the internet to my VM denied when I added no deny rule?

No default inbound rule allows it. AllowVNetInBound only covers sources in the VirtualNetwork tag, and AllowAzureLoadBalancerInBound only covers Azure health probes, not real traffic to your VM. The flow reaches DenyAllInbound (65500) unless a custom rule allows it.

Can two VMs in the same subnet reach each other by default?

Yes. A default rule allows traffic inside the subnet. The subnet NSG still applies to that traffic, so a rule in it that denies all inbound and outbound traffic stops the two VMs from communicating.

What if only the subnet or only the NIC has an NSG?

Then only that NSG is processed. In the Microsoft Learn example, VM2 has no NIC NSG, so it receives whatever the subnet NSG allows, and VM3 sits in a subnet with no NSG, so its NIC NSG alone processes the traffic. Every problem in this drill has both.

Do I need a rule for the reply traffic?

No. An NSG is stateful: a flow record is created for existing connections. If an outbound rule allows traffic to any address over port 80, you do not need an inbound rule for the response, and the same holds the other way round.

What do VirtualNetwork, Internet and AzureLoadBalancer mean in a rule?

They are service tags, not IP addresses. VirtualNetwork covers the virtual network address space, plus connected on-premises and peered networks. Internet is the address space outside the virtual network that is reachable by the public internet. AzureLoadBalancer is the address that Azure health probes come from.

Is 0.0.0.0/0 the same as Any?

Yes. Microsoft Learn lists the default rules with 0.0.0.0/0, which represents all IP addresses, and says the Azure portal, Azure CLI and PowerShell can use * or Any for it. This drill shows Any.

How do I check the result on a real VM?

View the effective security rules of the network interface, or run IP flow verify in Azure Network Watcher. IP flow verify tells you whether a flow is allowed or denied and which security rule is responsible.

Sources
  • Microsoft Learn, How network security groups filter network traffic: inbound traffic is processed by the subnet NSG, then the NIC NSG; outbound traffic by the NIC NSG, then the subnet NSG; a flow the first NSG denies is not evaluated by the second; both must allow a flow; the same order for traffic inside a subnet; effective security rules and IP flow verify.
  • Microsoft Learn, Azure network security groups overview: rule properties (priority 100 to 4096, lower numbers first, processing stops at the first match, source and destination forms, protocols, port ranges), the six default rules with their numbers, 0.0.0.0/0 and Any, stateful flow records.
  • Microsoft Learn, Azure service tags overview: what the VirtualNetwork, Internet and AzureLoadBalancer tags cover.
  • Microsoft Learn, Study guide for Exam AZ-104 (Evaluate effective security rules in NSGs) and Study guide for Exam AZ-700 (Create and configure NSG inbound and outbound security rules).
  • Checked 20 November 2026. The tool's own approach: problems are invented; every problem has a subnet NSG and a NIC NSG with two custom rules each; flows are TCP or UDP from or to the internet or the same virtual network. ICMP, health probes, application security groups, security admin rules and peered networks are left out. For an allowed flow the drill asks for the rule that allows it in the NSG processed last. An independent re-solver (Python ipaddress sets, the effective action of each NSG) agreed with the drill on 20,000 generated problems.

Checked 20 November 2026 against Microsoft Learn (Azure Virtual Network documentation) and the AZ-104 and AZ-700 study guides.

More free tools

All free tools