VM1 is in Subnet1 of a virtual network named VNet1. NSG-A is associated with Subnet1, and NSG-B is associated with the network interface of VM1. The custom rules are shown in the exhibit; no other custom rules exist in either NSG.
VM1 initiates an outbound HTTPS connection (TCP 443) to a public website.
| NSG | Associated with | Direction | Priority | Destination | Port | Protocol | Access |
|---|---|---|---|---|---|---|---|
| NSG-A | Subnet1 | Outbound | 200 | Internet | 443 | TCP | Deny |
| NSG-B | VM1 network interface | Outbound | 200 | Internet | 443 | TCP | Allow |
Which NSG does Azure evaluate first for this connection, and is the connection ultimately allowed or blocked?
When an NSG is associated with both a subnet and a network interface in that subnet, Azure evaluates both and the traffic must be allowed by each. For outbound traffic the order is the reverse of inbound: the NIC-associated NSG is processed first, then the subnet-associated NSG. NSG-B allows the HTTPS flow, but NSG-A on Subnet1 then denies it, so the connection is blocked.
- Correct: NSG-B first; NSG-A blocks the connection. For outbound traffic the NIC NSG (NSG-B) is evaluated before the subnet NSG (NSG-A), and traffic must pass both; NSG-B allows it but NSG-A denies it, so it is blocked.
- Not correct: NSG-A first; NSG-B allows the connection. Both parts are wrong: outbound traffic is evaluated at the NIC NSG first, and NSG-A's deny rule blocks the flow because traffic must pass both NSGs.
- Not correct: NSG-B first; NSG-B allows the connection. The order is right, but an allow in the NIC NSG is not enough; when NSGs are associated with both the NIC and the subnet, the traffic must pass both, and NSG-A denies it.
- Not correct: NSG-A first; NSG-A blocks the connection. The outcome is right but the order is wrong: subnet-first evaluation applies to inbound traffic, while outbound traffic is evaluated at the network interface first.