1. Packages
  2. Azure Classic
  3. API Docs
  4. network
  5. getVirtualNetworkPeering

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

azure.network.getVirtualNetworkPeering

Explore with Pulumi AI

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

Use this data source to access information about an existing virtual network peering.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const example = azure.network.getVirtualNetwork({
    name: "vnet01",
    resourceGroupName: "networking",
});
const exampleGetVirtualNetworkPeering = example.then(example => azure.network.getVirtualNetworkPeering({
    name: "peer-vnet01-to-vnet02",
    virtualNetworkId: example.id,
}));
export const id = exampleGetVirtualNetworkPeering.then(exampleGetVirtualNetworkPeering => exampleGetVirtualNetworkPeering.id);
Copy
import pulumi
import pulumi_azure as azure

example = azure.network.get_virtual_network(name="vnet01",
    resource_group_name="networking")
example_get_virtual_network_peering = azure.network.get_virtual_network_peering(name="peer-vnet01-to-vnet02",
    virtual_network_id=example.id)
pulumi.export("id", example_get_virtual_network_peering.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := network.LookupVirtualNetwork(ctx, &network.LookupVirtualNetworkArgs{
			Name:              "vnet01",
			ResourceGroupName: "networking",
		}, nil)
		if err != nil {
			return err
		}
		exampleGetVirtualNetworkPeering, err := network.LookupVirtualNetworkPeering(ctx, &network.LookupVirtualNetworkPeeringArgs{
			Name:             "peer-vnet01-to-vnet02",
			VirtualNetworkId: example.Id,
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("id", exampleGetVirtualNetworkPeering.Id)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var example = Azure.Network.GetVirtualNetwork.Invoke(new()
    {
        Name = "vnet01",
        ResourceGroupName = "networking",
    });

    var exampleGetVirtualNetworkPeering = Azure.Network.GetVirtualNetworkPeering.Invoke(new()
    {
        Name = "peer-vnet01-to-vnet02",
        VirtualNetworkId = example.Apply(getVirtualNetworkResult => getVirtualNetworkResult.Id),
    });

    return new Dictionary<string, object?>
    {
        ["id"] = exampleGetVirtualNetworkPeering.Apply(getVirtualNetworkPeeringResult => getVirtualNetworkPeeringResult.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.network.NetworkFunctions;
import com.pulumi.azure.network.inputs.GetVirtualNetworkArgs;
import com.pulumi.azure.network.inputs.GetVirtualNetworkPeeringArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var example = NetworkFunctions.getVirtualNetwork(GetVirtualNetworkArgs.builder()
            .name("vnet01")
            .resourceGroupName("networking")
            .build());

        final var exampleGetVirtualNetworkPeering = NetworkFunctions.getVirtualNetworkPeering(GetVirtualNetworkPeeringArgs.builder()
            .name("peer-vnet01-to-vnet02")
            .virtualNetworkId(example.applyValue(getVirtualNetworkResult -> getVirtualNetworkResult.id()))
            .build());

        ctx.export("id", exampleGetVirtualNetworkPeering.applyValue(getVirtualNetworkPeeringResult -> getVirtualNetworkPeeringResult.id()));
    }
}
Copy
variables:
  example:
    fn::invoke:
      function: azure:network:getVirtualNetwork
      arguments:
        name: vnet01
        resourceGroupName: networking
  exampleGetVirtualNetworkPeering:
    fn::invoke:
      function: azure:network:getVirtualNetworkPeering
      arguments:
        name: peer-vnet01-to-vnet02
        virtualNetworkId: ${example.id}
outputs:
  id: ${exampleGetVirtualNetworkPeering.id}
Copy

Using getVirtualNetworkPeering

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getVirtualNetworkPeering(args: GetVirtualNetworkPeeringArgs, opts?: InvokeOptions): Promise<GetVirtualNetworkPeeringResult>
function getVirtualNetworkPeeringOutput(args: GetVirtualNetworkPeeringOutputArgs, opts?: InvokeOptions): Output<GetVirtualNetworkPeeringResult>
Copy
def get_virtual_network_peering(name: Optional[str] = None,
                                virtual_network_id: Optional[str] = None,
                                opts: Optional[InvokeOptions] = None) -> GetVirtualNetworkPeeringResult
def get_virtual_network_peering_output(name: Optional[pulumi.Input[str]] = None,
                                virtual_network_id: Optional[pulumi.Input[str]] = None,
                                opts: Optional[InvokeOptions] = None) -> Output[GetVirtualNetworkPeeringResult]
Copy
func LookupVirtualNetworkPeering(ctx *Context, args *LookupVirtualNetworkPeeringArgs, opts ...InvokeOption) (*LookupVirtualNetworkPeeringResult, error)
func LookupVirtualNetworkPeeringOutput(ctx *Context, args *LookupVirtualNetworkPeeringOutputArgs, opts ...InvokeOption) LookupVirtualNetworkPeeringResultOutput
Copy

> Note: This function is named LookupVirtualNetworkPeering in the Go SDK.

public static class GetVirtualNetworkPeering 
{
    public static Task<GetVirtualNetworkPeeringResult> InvokeAsync(GetVirtualNetworkPeeringArgs args, InvokeOptions? opts = null)
    public static Output<GetVirtualNetworkPeeringResult> Invoke(GetVirtualNetworkPeeringInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetVirtualNetworkPeeringResult> getVirtualNetworkPeering(GetVirtualNetworkPeeringArgs args, InvokeOptions options)
public static Output<GetVirtualNetworkPeeringResult> getVirtualNetworkPeering(GetVirtualNetworkPeeringArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: azure:network/getVirtualNetworkPeering:getVirtualNetworkPeering
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Name This property is required. string
The name of this virtual network peering.
VirtualNetworkId This property is required. string
The resource ID of the virtual network.
Name This property is required. string
The name of this virtual network peering.
VirtualNetworkId This property is required. string
The resource ID of the virtual network.
name This property is required. String
The name of this virtual network peering.
virtualNetworkId This property is required. String
The resource ID of the virtual network.
name This property is required. string
The name of this virtual network peering.
virtualNetworkId This property is required. string
The resource ID of the virtual network.
name This property is required. str
The name of this virtual network peering.
virtual_network_id This property is required. str
The resource ID of the virtual network.
name This property is required. String
The name of this virtual network peering.
virtualNetworkId This property is required. String
The resource ID of the virtual network.

getVirtualNetworkPeering Result

The following output properties are available:

AllowForwardedTraffic bool
Controls if forwarded traffic from VMs in the remote virtual network is allowed.
AllowGatewayTransit bool
Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
AllowVirtualNetworkAccess bool
Controls if the traffic from the local virtual network can reach the remote virtual network.
Id string
The provider-assigned unique ID for this managed resource.
Name string
OnlyIpv6PeeringEnabled bool
Specifies whether only IPv6 address space is peered for Subnet peering.
PeerCompleteVirtualNetworksEnabled bool
Specifies whether complete Virtual Network address space is peered.
RemoteVirtualNetworkId string
The full Azure resource ID of the remote virtual network.
UseRemoteGateways bool
Controls if remote gateways can be used on the local virtual network.
VirtualNetworkId string
AllowForwardedTraffic bool
Controls if forwarded traffic from VMs in the remote virtual network is allowed.
AllowGatewayTransit bool
Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
AllowVirtualNetworkAccess bool
Controls if the traffic from the local virtual network can reach the remote virtual network.
Id string
The provider-assigned unique ID for this managed resource.
Name string
OnlyIpv6PeeringEnabled bool
Specifies whether only IPv6 address space is peered for Subnet peering.
PeerCompleteVirtualNetworksEnabled bool
Specifies whether complete Virtual Network address space is peered.
RemoteVirtualNetworkId string
The full Azure resource ID of the remote virtual network.
UseRemoteGateways bool
Controls if remote gateways can be used on the local virtual network.
VirtualNetworkId string
allowForwardedTraffic Boolean
Controls if forwarded traffic from VMs in the remote virtual network is allowed.
allowGatewayTransit Boolean
Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
allowVirtualNetworkAccess Boolean
Controls if the traffic from the local virtual network can reach the remote virtual network.
id String
The provider-assigned unique ID for this managed resource.
name String
onlyIpv6PeeringEnabled Boolean
Specifies whether only IPv6 address space is peered for Subnet peering.
peerCompleteVirtualNetworksEnabled Boolean
Specifies whether complete Virtual Network address space is peered.
remoteVirtualNetworkId String
The full Azure resource ID of the remote virtual network.
useRemoteGateways Boolean
Controls if remote gateways can be used on the local virtual network.
virtualNetworkId String
allowForwardedTraffic boolean
Controls if forwarded traffic from VMs in the remote virtual network is allowed.
allowGatewayTransit boolean
Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
allowVirtualNetworkAccess boolean
Controls if the traffic from the local virtual network can reach the remote virtual network.
id string
The provider-assigned unique ID for this managed resource.
name string
onlyIpv6PeeringEnabled boolean
Specifies whether only IPv6 address space is peered for Subnet peering.
peerCompleteVirtualNetworksEnabled boolean
Specifies whether complete Virtual Network address space is peered.
remoteVirtualNetworkId string
The full Azure resource ID of the remote virtual network.
useRemoteGateways boolean
Controls if remote gateways can be used on the local virtual network.
virtualNetworkId string
allow_forwarded_traffic bool
Controls if forwarded traffic from VMs in the remote virtual network is allowed.
allow_gateway_transit bool
Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
allow_virtual_network_access bool
Controls if the traffic from the local virtual network can reach the remote virtual network.
id str
The provider-assigned unique ID for this managed resource.
name str
only_ipv6_peering_enabled bool
Specifies whether only IPv6 address space is peered for Subnet peering.
peer_complete_virtual_networks_enabled bool
Specifies whether complete Virtual Network address space is peered.
remote_virtual_network_id str
The full Azure resource ID of the remote virtual network.
use_remote_gateways bool
Controls if remote gateways can be used on the local virtual network.
virtual_network_id str
allowForwardedTraffic Boolean
Controls if forwarded traffic from VMs in the remote virtual network is allowed.
allowGatewayTransit Boolean
Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
allowVirtualNetworkAccess Boolean
Controls if the traffic from the local virtual network can reach the remote virtual network.
id String
The provider-assigned unique ID for this managed resource.
name String
onlyIpv6PeeringEnabled Boolean
Specifies whether only IPv6 address space is peered for Subnet peering.
peerCompleteVirtualNetworksEnabled Boolean
Specifies whether complete Virtual Network address space is peered.
remoteVirtualNetworkId String
The full Azure resource ID of the remote virtual network.
useRemoteGateways Boolean
Controls if remote gateways can be used on the local virtual network.
virtualNetworkId String

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi