An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
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
VirtualNetworkrule 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
VirtualNetworkexpansion.
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;
VirtualNetworkdoes 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
VirtualNetworkdepends 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
- Azure service tags overview for virtual network security
- NetworkInterfacesOperations interface-Property Details
- EffectiveNetworkSecurityRule interface-Property Details
- Microsoft.Network serviceGateways (deployment-language-terraform)
- Configure VPN gateway transit for virtual network peering
- How to configure subnet peering
- Azure virtual network traffic routing
- Route injection in spoke virtual networks
- What is Azure Virtual WAN?
- Troubleshoot RDP blocked by NSG rules on Azure Windows VMs
- Create, change, or delete a route table