irtualNetwork service tag – exact composition, scope, and API to retrieve its resolved prefixes

Rina Frusman 40 Reputation points
2026-11-25T13:45:35.42+00:00

We would appreciate an authoritative explanation of how the VirtualNetwork service tag is resolved in NSG rules.

  1. Composition: Which address prefixes exactly make up the VirtualNetwork tag? Please list all sources that contribute prefixes to it.
  2. Scope: Is the tag resolved per VNet, per subnet, or per network interface? Can two NICs in the same VNet get different resolved values?
  3. Influencing factors: How, if at all, does each of the following affect the tag's contents?
    • VNet peering settings (allowVirtualNetworkAccess, allowGatewayTransit, useRemoteGateways)
    • Subnet-level peering
    • VPN Gateway and ExpressRoute Gateway (static and BGP-learned prefixes)
    • The "Propagate gateway routes" setting on a route table
    • User-defined routes
    • Azure Route Server
    • Virtual WAN hub connections ( peered hubs and their spokes)
  4. Exclusions: Are there documented cases where a reachable network is not included in the tag?
  5. Retrieval: Is there a supported API, CLI, or SDK method to get the resolved prefixes of the VirtualNetwork tag for a given VNet or subnet? alternative to the effective routes per NIC
    • Is there a recommended approach for doing this at scale?
  6. Documentation: Please point us to the official documentation that defines this behavior.
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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-11-25T13:47:30.6433333+00:00

    VirtualNetwork has no supported VNet- or subnet-level “resolve” API; to obtain Azure’s actual expansion, query effective NSG rules on a NIC and read expandedSourceAddressPrefix or expandedDestinationAddressPrefix.

    Documented composition

    Microsoft defines VirtualNetwork as containing:

    • All address ranges configured in the local VNet address space.
    • Connected on-premises address spaces.
    • Peered VNet address spaces.
    • VNets connected through a virtual network gateway.
    • The host virtual IP address.
    • Prefixes used in user-defined routes (UDRs).
    • Potentially default routes. ^1^

    This definition is broader than “the local VNet.” It does not mean every reachable destination is necessarily included.

    Resolution scope

    Microsoft does not document VirtualNetwork as having one independently retrievable value per VNet or subnet. The supported observable expansion is part of an effective security rule, and effective security rules are retrieved for a NIC. The SDK operation is listEffectiveNetworkSecurityGroups(resourceGroupName, networkInterfaceName, ...). ^2^

    Returned rules can contain:

    • expandedSourceAddressPrefix
    • expandedDestinationAddressPrefix ^3^

    Therefore:

    • Two NIC queries can return different effective-rule sets because different subnet- and NIC-level NSGs apply.
    • The documentation supplied here does not establish that two NICs in the same VNet necessarily resolve the same VirtualNetwork rule differently, or that NIC attachment itself changes the tag.
    • Subnet-specific topology and routing can differ, but Microsoft does not formally document how every such route difference maps into VirtualNetwork expansion.

    Effects of each networking feature

    Feature Documented behavior Documented effect on VirtualNetwork
    VNet peering Peering adds system routes for peered address ranges. allowVirtualNetworkAccess controls whether the local VNet can access the remote VNet; gateway transit permits use of a remote gateway. ^4^ Peered VNets are explicitly included. The precise effect of each peering flag on tag expansion is not separately defined.
    allowGatewayTransit + useRemoteGateways Together, these let a spoke use the peer’s gateway. Gateway-connected routes propagate to participating peered VNets. ^5^ Gateway-connected networks are included by the broad definition, but no exact flag-to-prefix algorithm is published.
    Subnet-level peering Only selected subnets participate, although documented limitations can expose routes on nonparticipating subnets or over-advertise certain delegated-subnet routes. ^6^ No authoritative rule defines how these subnet-peering edge cases alter tag expansion. Inspect effective rules on affected NICs.
    VPN/ExpressRoute gateway Static local-network-gateway prefixes and BGP-learned on-premises prefixes become gateway routes. ^7^ Connected on-premises spaces and gateway-connected VNets are explicitly included; exact treatment of every learned route is not further specified.
    Propagate gateway routes Disabling propagation prevents gateway routes from being distributed to associated subnets. ^5^ Its precise effect on tag expansion is undocumented; do not treat effective-route absence alone as proof of tag exclusion.
    UDRs UDR prefixes are explicitly part of the documented tag definition. Included, although the documentation warns that the tag might also contain default routes.
    Azure Route Server Injects NVA-learned BGP routes into Azure routing; disabling gateway propagation can also prevent subnets from learning Route Server routes. ^8^ No official mapping from every Route Server route to tag membership is documented.
    Virtual WAN Hub routing uses connection association and route propagation, including transitive routing between connected networks. ^9^ Reachability through a hub, another hub, or another spoke is not documented as sufficient to guarantee inclusion. Query the workload NIC.

    Documented exclusions and caveats

    • Public Internet addresses are not included merely because they are reachable; VirtualNetwork does not represent Internet sources. ^10^
    • Peering is ordinarily nontransitive, and Virtual WAN reachability depends on hub route association and propagation. Reachability and service-tag membership should therefore not be treated as equivalent.
    • The Service Tag Discovery API and downloadable JSON are unsuitable for resolving this topology-dependent tag. They provide cloud/region service-tag datasets, while VirtualNetwork depends on customer network configuration. ^1^

    Retrieve the effective expansion

    Prerequisites are an authenticated Azure CLI session, read access to the NIC and related networking resources, and an effective NSG rule that references VirtualNetwork in the source or destination field.

    az network nic list-effective-nsg \
      --resource-group <resource-group> \
      --name <nic-name> \
      --query "value[].effectiveSecurityRules[
        sourceAddressPrefix=='VirtualNetwork' ||
        destinationAddressPrefix=='VirtualNetwork'
      ].{rule:name,source:expandedSourceAddressPrefix,
          destination:expandedDestinationAddressPrefix}" \
      --output json
    

    The equivalent SDK operation is asynchronous/poller-based. Effective-route inspection is separate:

    az network nic show-effective-route-table \
      --resource-group <resource-group> \
      --name <nic-name> \
      --output table
    

    Effective routes combine default, UDR, and gateway-propagated routes and are available for a NIC attached to a running VM. ^11^

    For scale, enumerate NICs and query representative workload NICs from each relevant subnet/topology class. Treat this as an observation strategy—not an authoritative VNet-level enumeration—and cache results, limit concurrency, and retry long-running calls rather than issuing unbounded parallel requests.


    References

    1. Azure service tags overview for virtual network security
    2. NetworkInterfacesOperations interface-Property Details
    3. EffectiveNetworkSecurityRule interface-Property Details
    4. Microsoft.Network serviceGateways (deployment-language-terraform)
    5. Configure VPN gateway transit for virtual network peering
    6. How to configure subnet peering
    7. Azure virtual network traffic routing
    8. Route injection in spoke virtual networks
    9. What is Azure Virtual WAN?
    10. Troubleshoot RDP blocked by NSG rules on Azure Windows VMs
    11. Create, change, or delete a route table
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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