How to find a resource name or id based on IP address (internal/external) in Azure.

Eric T 0 Reputation points
2024-10-10T19:03:45.3233333+00:00

I tried a few powershell commands to query and pull but not much success.

Would like to see if there was an easier way to pull up a list of all Azure resources/services/databases that are associated with an IP address.

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,775 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. KapilAnanth-MSFT 49,611 Reputation points Microsoft Employee Moderator
    2024-10-11T06:04:25.38+00:00

    @Eric T ,

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    Please note that your question is not rightly put.

    • Not all Azure PaaS resources have a Public IP even if they are accessible from Internet.
    • They have FQDNs
    • For e.g.,
      • A storage account's blob endPoint would have an FQDN of "<YOURSTORAGEACCOUNTNAME>.blob.core.windows.net"
      • The IP associated with it is not static and can change
      • Customers are requested to access this PaaS resource with the endPoint's FQDN and not the IP to which it resolved to
    • So, the PaaS resource never had an IP associated with it
      • The same goes for Azure Database which uses "<YOURDBName>.database.windows.net" endpoint.

    With that said, certain PaaS Services are associated with a Public IP

    • Provided that you create the Public IP as an independent resource along with the PaaS resource
    • Some e.g., include VPN gateway, Load Balancer, App Gateway, Virtual Machines (NICs), Azure Firewall
    • In these cases, we can query for the PaaS/IaaS services based on whether or not they contain IP Addresses.

    You can use : Azure Resource Graph

    The query would be something like,

    Resources
    | where properties contains "/providers/Microsoft.Network/publicIPAddresses/"
    | project name, id, type
    

    If you know the IP Address and would like to query for the resource that uses this IP,

    • First run,
    Resources
    | where type contains 'publicIPAddresses' and properties.ipAddress == "<YOURIPADDRESS>"
    | project id
    
    • This would give you the Public IP's Resource ID
    • Use this Resource ID in the below query to get the resource to which it is associated
    Resources
    | where properties contains "<RESOURCEIDFROMPREVIOUSQUERY>"
    
    
    • The above will list the resource which is using the Public IP

    NOTE:

    Hope this helps

    Thanks,

    Kapil


    Please Accept an answer if correct.

    Original posters help the community find answers faster by identifying the correct answer.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.