Hello @Anonymous ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I understand that you would like to know how to use Kusto Query for resource type "network security group" within Azure Resource Graph Explorer to display "sourcePortRange" value for "destinationPortRange" values 22 & 3389 in two separate columns along with the "networkSecurityGroupId" from the NSG security rules.
Below is the Kusto query that I used in my lab which displays the sourcePortRange in a column for destinationPortRange values 22 & 3389 in another column with the networkSecurityGroupId, name and access type.
resources
| where type startswith 'microsoft.network/networksecuritygroups'
| mv-expand rules=properties.securityRules
| where rules.properties.destinationPortRange in ("3389", "22")
| project
name = rules.name,
nsgid = id,
access = rules.properties.access,
DestPort = rules.properties.destinationPortRange,
SourcePort = rules.properties.sourcePortRange
Kindly let us know if the above helps or you need further assistance on this issue.
----------------------------------------------------------------------------------------------------------------
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.