A security rule filters traffic entering or leaving a network security group (NSG). It matches traffic by port, protocol, source, and destination, then allows or denies it. NSGs can protect a subnet or an individual VM through its network interface. section 4.3
The important settings are:
- Priority runs from the lowest number to the highest; once a rule matches, later rules do not process that packet. section 4.3
- Port accepts a number from 0 to 65,535 or Any, while protocol accepts TCP, UDP, or Any. section 4.3
- Sources and destinations can be Any, an IP address, a CIDR range, or an Azure service tag. section 4.3
- Action is Allow or Deny; overlapping rules deserve careful priorities, or the rule list can become network spaghetti. section 4.3
Allowing remote desktop
An Azure PowerShell configuration adds an inbound allowRDP rule for TCP port 3389, restricted to a specified source address, with priority 300. section 4.3
Table 4.3 Inbound security rules for a default NSG
| Priority |
Name |
Port |
Protocol |
Source |
Destination |
Action |
| 300 |
|
22 |
TCP |
Any |
Any |
Allow |
| 65000 |
|
Any |
Any |
VNet |
VNet |
Allow |
| 65001 |
|
Any |
Any |
Azure Load Balancer |
Any |
Allow |
| 65002 |
|
Any |
Any |
Any |
Any |
Deny |
Compare a default NSG's SSH allow rule with its built-in VNet, load-balancer, and deny-all rules. section 4.3

