Forum Discussion

Rahul_Mahajan's avatar
Rahul_Mahajan
Brass Contributor
Oct 15, 2019
Solved

VM with Public IP

Hi All,   Can someone help me with query to get list of VM names and public IP address assigned to them.   Also how to create view in dashboard for the same as I dont have permission to modify or...
  • Stanislav_Zhelyazkov's avatar
    Stanislav_Zhelyazkov
    Oct 18, 2019

    HiRahul_Mahajan 

    Here is a blog post about visualizing data from resource graph in Azure Dashboards: https://samcogan.com/visualise-your-azure-resource-with-resource-graph-explorer/

     

    Azure Monitor workbooks can also visualize data from the resource graph:

    https://docs.microsoft.com/en-us/azure/azure-monitor/app/usage-workbooks

     

    Below you can find the resource graph query. Keep in mind you can get only the IP address of static ip address:

    Resources | where type =~ "Microsoft.Network/networkInterfaces"
     | mv-expand properties.ipConfigurations
     | where isnotempty(properties_ipConfigurations.properties.publicIPAddress.id)
     | extend publicIpId = tostring(properties_ipConfigurations.properties.publicIPAddress.id)
      | join (
    	Resources | where type =~ "microsoft.network/publicipaddresses"
     ) on $left.publicIpId == $right.id
     | extend ipAddress = tostring(properties1.ipAddress)
     | extend publicIPAllocationMethod = tostring(properties1.publicIPAllocationMethod)
     | extend publicIpName = tostring(name1)
     | extend vmId = tostring(properties.virtualMachine.id)
     | where notempty(vmId)
      | join  (
    	 Resources | where type == "microsoft.compute/virtualmachines"
     ) on $left.vmId == $right.id
    | extend name = name2
    | extend resourceGroup = resourceGroup2
    | project name, resourceGroup,publicIpName, publicIPAllocationMethod, ipAddress
    

Resources