We recommend using Azure Native.
Azure v6.21.0 published on Friday, Mar 7, 2025 by Pulumi
azure.network.getVirtualNetworkPeering
Explore with Pulumi AI
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);
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)
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
	})
}
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),
    };
});
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()));
    }
}
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}
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>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]func LookupVirtualNetworkPeering(ctx *Context, args *LookupVirtualNetworkPeeringArgs, opts ...InvokeOption) (*LookupVirtualNetworkPeeringResult, error)
func LookupVirtualNetworkPeeringOutput(ctx *Context, args *LookupVirtualNetworkPeeringOutputArgs, opts ...InvokeOption) LookupVirtualNetworkPeeringResultOutput> 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)
}public static CompletableFuture<GetVirtualNetworkPeeringResult> getVirtualNetworkPeering(GetVirtualNetworkPeeringArgs args, InvokeOptions options)
public static Output<GetVirtualNetworkPeeringResult> getVirtualNetworkPeering(GetVirtualNetworkPeeringArgs args, InvokeOptions options)
fn::invoke:
  function: azure:network/getVirtualNetworkPeering:getVirtualNetworkPeering
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Name string
- The name of this virtual network peering.
- VirtualNetwork stringId 
- The resource ID of the virtual network.
- Name string
- The name of this virtual network peering.
- VirtualNetwork stringId 
- The resource ID of the virtual network.
- name String
- The name of this virtual network peering.
- virtualNetwork StringId 
- The resource ID of the virtual network.
- name string
- The name of this virtual network peering.
- virtualNetwork stringId 
- The resource ID of the virtual network.
- name str
- The name of this virtual network peering.
- virtual_network_ strid 
- The resource ID of the virtual network.
- name String
- The name of this virtual network peering.
- virtualNetwork StringId 
- The resource ID of the virtual network.
getVirtualNetworkPeering Result
The following output properties are available:
- AllowForwarded boolTraffic 
- Controls if forwarded traffic from VMs in the remote virtual network is allowed.
- AllowGateway boolTransit 
- Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
- AllowVirtual boolNetwork Access 
- 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
- OnlyIpv6Peering boolEnabled 
- Specifies whether only IPv6 address space is peered for Subnet peering.
- PeerComplete boolVirtual Networks Enabled 
- Specifies whether complete Virtual Network address space is peered.
- RemoteVirtual stringNetwork Id 
- The full Azure resource ID of the remote virtual network.
- UseRemote boolGateways 
- Controls if remote gateways can be used on the local virtual network.
- VirtualNetwork stringId 
- AllowForwarded boolTraffic 
- Controls if forwarded traffic from VMs in the remote virtual network is allowed.
- AllowGateway boolTransit 
- Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
- AllowVirtual boolNetwork Access 
- 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
- OnlyIpv6Peering boolEnabled 
- Specifies whether only IPv6 address space is peered for Subnet peering.
- PeerComplete boolVirtual Networks Enabled 
- Specifies whether complete Virtual Network address space is peered.
- RemoteVirtual stringNetwork Id 
- The full Azure resource ID of the remote virtual network.
- UseRemote boolGateways 
- Controls if remote gateways can be used on the local virtual network.
- VirtualNetwork stringId 
- allowForwarded BooleanTraffic 
- Controls if forwarded traffic from VMs in the remote virtual network is allowed.
- allowGateway BooleanTransit 
- Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
- allowVirtual BooleanNetwork Access 
- 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
- onlyIpv6Peering BooleanEnabled 
- Specifies whether only IPv6 address space is peered for Subnet peering.
- peerComplete BooleanVirtual Networks Enabled 
- Specifies whether complete Virtual Network address space is peered.
- remoteVirtual StringNetwork Id 
- The full Azure resource ID of the remote virtual network.
- useRemote BooleanGateways 
- Controls if remote gateways can be used on the local virtual network.
- virtualNetwork StringId 
- allowForwarded booleanTraffic 
- Controls if forwarded traffic from VMs in the remote virtual network is allowed.
- allowGateway booleanTransit 
- Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
- allowVirtual booleanNetwork Access 
- 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
- onlyIpv6Peering booleanEnabled 
- Specifies whether only IPv6 address space is peered for Subnet peering.
- peerComplete booleanVirtual Networks Enabled 
- Specifies whether complete Virtual Network address space is peered.
- remoteVirtual stringNetwork Id 
- The full Azure resource ID of the remote virtual network.
- useRemote booleanGateways 
- Controls if remote gateways can be used on the local virtual network.
- virtualNetwork stringId 
- allow_forwarded_ booltraffic 
- Controls if forwarded traffic from VMs in the remote virtual network is allowed.
- allow_gateway_ booltransit 
- Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
- allow_virtual_ boolnetwork_ access 
- 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_ boolpeering_ enabled 
- Specifies whether only IPv6 address space is peered for Subnet peering.
- peer_complete_ boolvirtual_ networks_ enabled 
- Specifies whether complete Virtual Network address space is peered.
- remote_virtual_ strnetwork_ id 
- The full Azure resource ID of the remote virtual network.
- use_remote_ boolgateways 
- Controls if remote gateways can be used on the local virtual network.
- virtual_network_ strid 
- allowForwarded BooleanTraffic 
- Controls if forwarded traffic from VMs in the remote virtual network is allowed.
- allowGateway BooleanTransit 
- Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network.
- allowVirtual BooleanNetwork Access 
- 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
- onlyIpv6Peering BooleanEnabled 
- Specifies whether only IPv6 address space is peered for Subnet peering.
- peerComplete BooleanVirtual Networks Enabled 
- Specifies whether complete Virtual Network address space is peered.
- remoteVirtual StringNetwork Id 
- The full Azure resource ID of the remote virtual network.
- useRemote BooleanGateways 
- Controls if remote gateways can be used on the local virtual network.
- virtualNetwork StringId 
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the azurermTerraform Provider.