Contoso runs the front-end, API, and database VMs of an ordering app in one virtual network and placed their NICs in the application security groups asg-front, asg-api, and asg-sql. NSG1, associated with the subnets, has no custom inbound rules yet. Which inbound rules should you add to NSG1 so that only asg-api can connect to TCP 1433 on asg-sql?
Show answer and explanation
Answer: B
Explanation
Network security group rules are processed in priority order with lower numbers first, and processing stops once traffic matches a rule.[2] Because the AllowVNetInBound default security rule allows all communication between resources in the same virtual network, you need a deny rule for traffic from all resources.[1] When the allow rule has a lower number than the deny rule, asg-api traffic is allowed first and all other traffic is blocked.[1]
With only the allow rule, traffic from asg-front also matches AllowVNetInBound at priority 65000 and is allowed.[2] With the deny rule at 110, asg-api traffic also stops at the deny rule and never reaches the allow rule at 120.[2] Inbound traffic from the internet is already denied by the DenyAllInbound default security rule, so blocking traffic from the same virtual network requires a deny rule whose source is Any.[1]