【问题标题】:list of public ips along with subsciption name, resource type in Azure using Azure Resource Graph使用 Azure Resource Graph 的 Azure 中的公共 ips 列表以及订阅名称、资源类型
【发布时间】:2021-11-03 04:16:54
【问题描述】:

我需要使用 Azure Resource Graph 获取 Azure 中的公共 ips 列表以及订阅名称、资源类型(例如 vm、应用程序网关、elb)。我也想显示公共 IP 地址。

这是我的草稿,但我不知道如何列出其他资源:

Resources
| where type =~ 'microsoft.compute/virtualmachines'
|project name, OS=tostring(properties.storageProfile.osDisk.osType), location, 
ipid = tolower(tostring(properties.networkProfile.networkInterfaces[0].id))
| join kind=leftouter (
    Resources
    | where type =~ 'microsoft.network/networkinterfaces'
    | project ipid = tolower(id), elasticPoolName = name, 
    publicIPid = properties.ipConfigurations[0].properties.publicIPAddress.id)
    | join kind=leftouter (
        Resources
        | where type =~ 'microsoft.network/applicationGateways'
        | project name, publicIP
on ipid
| project-away ipid
| project name, OS, location, pubipid=tolower(tostring(publicIPid))
| join kind=leftouter (
    Resources
    | where type =~ 'microsoft.network/publicipaddresses'
    | project pubipid = tolower(id), publicIP = properties.ipAddress)
on pubipid
| project-away pubipid
| project name, publicIP, OS, location

【问题讨论】:

  • 如果回答对您有帮助,请Accept it as an Answer,以便遇到相同问题的其他人可以找到此解决方案并解决他们的问题。

标签: azure kql kusto-explorer


【解决方案1】:

您可以使用以下查询来获取所有 IP 地址的关联资源提供程序:

Resources
| where type contains 'publicIPAddresses' and isnotempty(properties.ipAddress)
| project name,id= split(properties.ipConfiguration.id,"providers",1),ip_address=properties.ipAddress

输出:

注意:

  • 如上图所示,我们得到了提供者的输出 例如,在 id 部分中使用名称 /Microsoft.Network/loadBalancers/kubernetes/frontendIPConfigurations/0713fba8-23fa-43bc-a003-b4197500b399, 那么这意味着公共 IP 与名称为 kubernetesLoad balancer 相关联,如 1 所示。
  • 如果关联与网络接口,则网络接口可能与计算资源(如 VM 等)或 一个 DNS,如 2 所示。
  • 如果它没有与任何资源相关联,那么它会返回null,如 3 所示。
  • 在 4 中它被 Bastion Host 使用。
  • 在 5 中,它被 VNET 网关使用。

【讨论】:

    猜你喜欢
    • 2019-11-25
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 2021-06-29
    • 2018-04-18
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    相关资源
    最近更新 更多