01 Run account list command (Windows/macOS/Linux) using custom query filters to list the IDs of the subscriptions available in your Azure account:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az account list
--query '[*].id'
02 The command output should return the requested subscription identifiers:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
"abcdabcd-1234-abcd-1234-abcdabcdabcd",
"abcd1234-abcd-1234-abcd-abcd1234abcd",
]
03 Run network nsg list command (Windows/macOS/Linux) using custom query filters to list the names of all network security groups (and the name of their associated resource groups) available in the selected Azure subscription:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az network nsg list
--subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
--output table
--query '[*].{name:name, resourceGroup:resourceGroup}'
04 The command output should return a table with requested information:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
Name ResourceGroup
--------------------- ------------------------------
cc-prod-endpoint-nsg cloud-shell-storage-westeurope
cc-dev-web-server-nsg cloud-shell-storage-westeurope
05 Run az network nsg rule list command (Windows/macOS/Linux) using the name of the Azure network security group (NSG) that you want to examine and its associated resource group as identifier parameters, to describe the NSG rules that allow inbound/ingress traffic to the virtual machines associated with the selected network security group:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az network nsg rule list
--nsg-name cc-prod-endpoint-nsg
--resource-group cloud-shell-storage-westeurope
--query "[?direction=='Inbound' && access=='Allow']"
06 The command output should return the requested network security group rule(s) metadata:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
{
"access": "Allow",
"description": null,
"destinationAddressPrefix": "*",
"destinationAddressPrefixes": [],
"destinationApplicationSecurityGroups": null,
"destinationPortRange": "0-65535",
"destinationPortRanges": []
,
"direction": "Inbound",
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/networkSecurityGroups/cc-prod-endpoint-nsg/securityRules/cc-web-inbound-access",
"name": "cc-web-inbound-access",
"priority": 100,
"protocol": "TCP",
"provisioningState": "Succeeded",
"resourceGroup": "cloud-shell-storage-westeurope",
"sourceAddressPrefix": "*",
"sourceAddressPrefixes": [],
"sourceApplicationSecurityGroups": null,
"sourcePortRange": "*",
"sourcePortRanges": [],
"type": "Microsoft.Network/networkSecurityGroups/securityRules"
}
]
If the
"destinationPortRange" and/or
"destinationPortRanges" attributes value is set to range or ports such as 0 – 65535, 80 – 8080 and 111 – 32800, the selected Azure network security group (NSG) is using range of ports to allow traffic, therefore the inbound/ingress access to the associated Microsoft Azure virtual machine(s) is not secured.
07 Repeat step no. 5 and 6 for each Azure network security group created within the selected subscription.
08 Repeat steps no. 3 – 7 for each subscription available in your Microsoft Azure cloud account.