Forum Discussion
Is there a better way to search by IP address in the portal? Both Public & Private?
- Aug 23, 2019
Are you looking for Public or Private IPs? It sounds like Public IPs. If that's the case, you can in the Portal, go to "All Services" then search for "Public IP Addresses" (which I made a favorite), then once you go to that, you can click on "Edit Columns" at the top, and add "IP Address" as a column. Then you can find the Public IP that you're looking for and the name of the Public IP. If you click on it, you can see which VM it is associated with. That might be a little simpler for you possibly?
Maybe on the Private IP side go to the VNet and look at the resources that have IPs in that VNet? Are you using Azure DNS or your own DNS in your Private network side?
Install-Module -Name Az
Import-Module Az
Here is an ARG (Azure Resource Graph) Query that might help to get you started:
// Get vmNics with IP Addresses
// Aggregation of all the vmNics by the lowercase VM id
Resources
| where type =~ 'microsoft.compute/virtualmachines'
| project vmId = tolower(tostring(id)), vmName = name
| join (Resources
| where type =~ 'microsoft.network/networkinterfaces'
| mv-expand ipconfig=properties.ipConfigurations
| project vmId = tolower(tostring(properties.virtualMachine.id)), privateIp = ipconfig.properties.privateIPAddress, publicIpId = tostring(ipconfig.properties.publicIPAddress.id)
| join kind=leftouter (Resources
| where type =~ 'microsoft.network/publicipaddresses'
| project publicIpId = id, publicIp = properties.ipAddress
) on publicIpId
| project-away publicIpId, publicIpId1
| summarize privateIps = make_list(privateIp), publicIps = make_list(publicIp) by vmId
) on vmId
| project-away vmId1
| sort by vmName asc
- RobBeyreisApr 21, 2023Copper Contributor
BrooksV I also found a more generic property search for things that regex to IP helps find all types of resources (NSGs, vNETs, NICs):
Resources | where properties matches regex @'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' | extend IP=extract_all(@'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d{1,2}){0,1})',tostring(properties)) | project name, type, IP, location, resourceGroup, subscriptionId, properties | mv-expand IP | order by type,name