website logo
HomeGithubSlack
⌘K
Overview
Quick Start
Supported Services
Running CloudGraph in EKS
Compliance
Rules Engine
AWS
Querying AWS Data
AWS Policy Packs
Billing Data
Services
Azure
Querying Azure Data
Azure Policy Packs
Services
GCP
Querying GCP Data
GCP Policy Packs
Services
K8s
Querying Kubernetes Data
Services
Docs powered by archbee 

Virtual Network

16min

Note: if you are running CloudGraph locally you can view the interactive, automatically generated documentation in either GraphQL Playground or Altair by clicking the docs button on the right-hand side of the screen. After reading the below information we highly suggest you use one of these tools to test your queries as they will autocomplete fields for you and let you know if your queries are valid before you even submit them.

Overview

You can currently query the following attributes and connections on an Azure Virtual Network

GraphQL
|
query {
  queryazureVirtualNetwork{
    id
    name
    type
    kind
    subscriptionId
    region
    resourceGroupId
    addressSpacePrefixes
    dnsServers
    ddosProtectionPlans{
      id
      name
      type
      resourceGuid
      etag
    }
    enableDdosProtection
    enableVmProtection
    flowTimeoutInMinutes
    provisioningState
    resourceGuid
    firewalls{
      id
      # Other fields and connections here...
    }
    networkInterfaces{
      id
      # Other fields and connections here...
    }
    virtualMachines{
      id
      # Other fields and connections here...
    }
    resourceGroup{
      id
      # Other fields and connections here...
    }
    tags{
      id
      key
      value
    }
  }
}


Filtering

Get data for a single Azure Virtual Network key that you know the ID for:

GraphQL
|
query {
  getazureVirtualNetwork(id: "12345") {
    id
    # Other fields and connections here...
  }
}


Get data for all of the Virtual Networks in a certain Azure subscription:

GraphQL
|
query {
  queryazureVirtualNetwork(filter: { subscriptionId: { eq: "12345" } }) {
    id
    # Other fields and connections here...
  }
}

# Note that in addition to "subscriptionId" you can
# Filter based on any of the following attributes:

# id
# name
# type
# kind
# subscriptionId
# region
# resourceGroupId
# addressSpacePrefixes
# dnsServers
# enableDdosProtection
# enableVmProtection
# flowTimeoutInMinutes
# provisioningState
# resourceGuid

# And the following Dgraph filters can also be applied:

# has
# and
# or
# not
# regexp (regular expressions)

# fulltext filters

# alloftext
# anyoftext


Get data for all of the Virtual Networks that are NOT in a certain Azure subscription:

GraphQL
|
query {
  queryazureVirtualNetwork(filter: { not: { subscriptionId: { eq: "12345" } } }) {
    id
    # Other fields and connections here...
  }
}


Advanced Filtering

Get data for all of the Virtual Networks that are connected to a virtualMachine:

GraphQL
|
query {
  queryazureVirtualNetwork(filter: { has: virtualMachines }) {
    id
    # Other fields and connections here...
  }
}

# Note that in addition to "virtualMachines" you can filter
# Using "has" based on any of the following attributes:

# addressSpacePrefixes
# dnsServers
# enableDdosProtection
# enableVmProtection
# flowTimeoutInMinutes
# provisioningState
# resourceGuid
# firewalls
# networkInterfaces



Ordering

You can order the results you get back either asc or desc depending on your preference:

GraphQL
|
query {
  queryazureVirtualNetwork(order: { desc: name }) {
    id
    # Other fields and connections here...
  }
}

# Note that in addition to "name" you can filter
# Using "asc" or "desc" based on any of the following attributes:

# id
# type
# kind
# subscriptionId
# region
# resourceGroupId
# addressSpacePrefixes
# dnsServers
# enableDdosProtection
# enableVmProtection
# flowTimeoutInMinutes
# provisioningState
# resourceGuid


Only select and return the first two Virtual Networks that are found:

GraphQL
|
query {
  queryazureVirtualNetwork(first: 2, order: { desc: name }) {
    id
    # Other fields and connections here...
  }
}


Only select and return the first two Virtual Networks that are found, but offset by one so keys two & three are returned:

GraphQL
|
query {
  queryazureVirtualNetwork(first: 2, order: { desc: name }, offset: 1) {
    id
    # Other fields and connections here...
  }
}


Aggregation

Count the number of Virtual Networks across all scanned Azure subscriptions:

GraphQL
|
query {
  aggregateazureVirtualNetwork {
    count
    # Other fields and connections here...
  }
}

# Note that in addition to "count" you can request the
# Following min and max values based on attributes of your Disks:

# idMin
# idMax
# nameMin
# nameMax
# typeMin
# typeMax
# kindMin
# kindMax
# subscriptionIdMin
# subscriptionIdMax
# regionMin
# regionMax
# resourceGroupIdMin
# resourceGroupIdMax
# flowTimeoutInMinutesMin
# flowTimeoutInMinutesMax
# flowTimeoutInMinutesSum
# flowTimeoutInMinutesAvg
# provisioningStateMin
# provisioningStateMax
# resourceGuidMin
# resourceGuidMax



Count the number of Virtual Networks in a single account. Note that you can apply all of the same filters that are listed above to aggregate queries:

GraphQL
|
query {
  aggregateazureVirtualNetwork(filter: { subscriptionId: { eq: "12345" } }) {
    count
    # Other fields and connections here...
  }
}


Examples

Find all of the Virtual Networks that are in the eastus region across all your accounts:

GraphQL
|
query {
  queryazureVirtualNetwork(filter: { region: { eq: "eastus" } }) {
    id
    # Other fields and connections here...
  }
}


Find all of the Virtual Networks that have a tag of Environment:Production for a single Azure Subscription:

GraphQL
|
query {
  queryazureTag(
    filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
  ) {
    virtualNetworks(filter: { subscriptionId: { eq: "12345" } }) {
      id
      # Other fields and connections here...
    }
  }
}


With CloudGraph you can run multiple queries at the same time so you can combine the above two queries if you like:

GraphQL
|
query {
  queryazureVirtualNetwork(filter: { region: { eq: "eastus" } }) {
    id
    # Other fields and connections here...
  }
  queryazureTag(
    filter: { key: { eq: "Environment" }, value: { eq: "Production" } }
  ) {
    virtualNetworks(filter: { subscriptionId: { eq: "12345" } }) {
      id
      # Other fields and connections here...
    }
  }
}


Kitchen Sink

Putting it all together; get all data for all Virtual Networks across all regions for all scanned Azure subscriptions in a single query. For the purposes of this example, we will only get direct children of the keys but if you want to it's easy to go from say, disk -> virtualMachine -> networkInterface ...etc:

GraphQL
|
query {
  queryazureVirtualNetwork{
    id
    name
    type
    kind
    subscriptionId
    region
    resourceGroupId
    addressSpacePrefixes
    dnsServers
    ddosProtectionPlans{
      id
      name
      type
      resourceGuid
      etag
    }
    enableDdosProtection
    enableVmProtection
    flowTimeoutInMinutes
    provisioningState
    resourceGuid
    firewalls{
      name
      type
      kind
      subscriptionId
      region
      resourceGroupId
      applicationRuleCollections{
        id
        name
        priority
        action
        rules{
          id
          name
          description
          sourceAddresses
          protocols{
            id
            protocolType
            port
          }
          targetFqdns
          fqdnTags
          sourceIpGroups
        }
        provisioningState
      }
      natRuleCollections{
        id
        name
        priority
        action
        rules{
          id
          name
          description
          sourceAddresses
          destinationAddresses
          destinationPorts
          protocols
          translatedAddress
          translatedPort
          translatedFqdn
          sourceIpGroups
        }
        provisioningState
      }
      networkRuleCollections{
        id
        name
        priority
        action
        rules{
          id
          name
          description
          protocols
          sourceAddresses
          destinationAddresses
          destinationPorts
          destinationFqdns
          sourceIpGroups
          destinationIpGroups
        }
        provisioningState
      }
      ipConfigurations{
        id
        name
        privateIPAddress
        subnet
        publicIPAddress
        provisioningState
        type
      }
      managementIpConfiguration{
        id
        privateIPAddress
        subnet
        publicIPAddress
        provisioningState
        name
        type
      }
      provisioningState
      threatIntelMode
      virtualHub
      firewallPolicy
      hubIPAddresses{
        publicIPs
        privateIPAddress
      }
      ipGroups{
        id
        changeNumber
      }
      additionalProperties{
        id
        key
        value
      }
      zones
      region
      tags{
        id
        key
        value
      }
      resourceGroup{
        id
        # Other fields and connections here...
      }
      virtualNetworks{
        id
        # Other fields and connections here...
      }
      publicIps{
        id
        # Other fields and connections here...
      }
    }
    networkInterfaces{
      id
      name
      type
      kind
      subscriptionId
      region
      resourceGroupId
      macAddress
      privateIpAddress
      internalDnsNameLabel
      enableIpForwarding
      virtualMachineId
      enableAcceleratedNetworking
      internalDomainNameSuffix
      ipConfiguration{
        gatewayLoadBalancer{
          id
        }
        privateIPAddress
        privateIPAllocationMethod
        privateIPAddressVersion
        subnetId
        primary
        provisioningState
        id
        name
        etag
        type
      }
      appliedDnsServers
      dnsServers
      publicIps{
        id
        # Other fields and connections here...
      }
      resourceGroup{
        id
        # Other fields and connections here...
      }
      securityGroups{
        id
        # Other fields and connections here...
      }
      virtualMachines{
        id
        # Other fields and connections here...
      }
      virtualNetworks{
        id
        # Other fields and connections here...
      }
    }
    virtualMachines{
      id
      name
      type
      kind
      subscriptionId
      region
      resourceGroupId
      managedBy
      vmSize
      osProfile{
        computerName
        windowsConfiguration{
          provisionVMAgent
          enableAutomaticUpdates
          timeZone
        }
        linuxConfiguration{
          disablePasswordAuthentication
          provisionVMAgent
        }
        allowExtensionOperations
        requireGuestProvisionSignal
      }
      osType
      storageImageReference {
        publisher
        offer
        sku
        version
        exactVersion
      }
      bootDiagnostics
      licenseType
      tags{
        id
        key
        value
      }
      disks{
        id
        # Other fields and connections here...
      }
      networkInterfaces{
        id
        # Other fields and connections here...
      }
      virtualNetworks{
        id
        # Other fields and connections here...
      }
      resourceGroup{
        id
        # Other fields and connections here...
      }
    }
    resourceGroup{
      id
      name
      type
      kind
      subscriptionId
      region
      managedBy
      disks {
        id
        # Other fields and connections here...
      }
      dns {
        id
        # Other fields and connections here...
      }
      firewalls {
        id
        # Other fields and connections here...
      }
      functionApps {
        id
        # Other fields and connections here...
      }
      keyVaults {
        id
        # Other fields and connections here...
      }
      networkInterfaces {
        id
        # Other fields and connections here...
      }
      publicIps {
        id
        # Other fields and connections here...
      }
      securityGroups {
        id
        # Other fields and connections here...
      }
      storageAccounts {
        id
        # Other fields and connections here...
      }
      storageContainers {
        id
        # Other fields and connections here...
      }
      virtualMachines {
        id
        # Other fields and connections here...
      }
      virtualNetworks {
        id
        # Other fields and connections here...
      }
      tags{
        id
        key
        value
      }
    }
  }
}


References

Dgraph documentation on querying

Azure Virtual Networks and subnets Documentation

Updated 03 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
Virtual Machine Scale Set
NEXT
Querying GCP Data
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Filtering
Advanced Filtering
Ordering
Aggregation
Examples
Kitchen Sink
References