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

We recommend using Azure Native.

Azure v6.10.0 published on Tuesday, Nov 19, 2024 by Pulumi

azure.network.getVirtualNetwork

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure v6.10.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Use this data source to access information about an existing Virtual Network.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const example = azure.network.getVirtualNetwork({
        name: "production",
        resourceGroupName: "networking",
    });
    export const virtualNetworkId = example.then(example => example.id);
    
    import pulumi
    import pulumi_azure as azure
    
    example = azure.network.get_virtual_network(name="production",
        resource_group_name="networking")
    pulumi.export("virtualNetworkId", example.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:              "production",
    			ResourceGroupName: "networking",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("virtualNetworkId", example.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 = "production",
            ResourceGroupName = "networking",
        });
    
        return new Dictionary<string, object?>
        {
            ["virtualNetworkId"] = example.Apply(getVirtualNetworkResult => getVirtualNetworkResult.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 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("production")
                .resourceGroupName("networking")
                .build());
    
            ctx.export("virtualNetworkId", example.applyValue(getVirtualNetworkResult -> getVirtualNetworkResult.id()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: azure:network:getVirtualNetwork
          Arguments:
            name: production
            resourceGroupName: networking
    outputs:
      virtualNetworkId: ${example.id}
    

    Using getVirtualNetwork

    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 getVirtualNetwork(args: GetVirtualNetworkArgs, opts?: InvokeOptions): Promise<GetVirtualNetworkResult>
    function getVirtualNetworkOutput(args: GetVirtualNetworkOutputArgs, opts?: InvokeOptions): Output<GetVirtualNetworkResult>
    def get_virtual_network(name: Optional[str] = None,
                            resource_group_name: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetVirtualNetworkResult
    def get_virtual_network_output(name: Optional[pulumi.Input[str]] = None,
                            resource_group_name: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetVirtualNetworkResult]
    func LookupVirtualNetwork(ctx *Context, args *LookupVirtualNetworkArgs, opts ...InvokeOption) (*LookupVirtualNetworkResult, error)
    func LookupVirtualNetworkOutput(ctx *Context, args *LookupVirtualNetworkOutputArgs, opts ...InvokeOption) LookupVirtualNetworkResultOutput

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

    public static class GetVirtualNetwork 
    {
        public static Task<GetVirtualNetworkResult> InvokeAsync(GetVirtualNetworkArgs args, InvokeOptions? opts = null)
        public static Output<GetVirtualNetworkResult> Invoke(GetVirtualNetworkInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVirtualNetworkResult> getVirtualNetwork(GetVirtualNetworkArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azure:network/getVirtualNetwork:getVirtualNetwork
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Specifies the name of the Virtual Network.
    ResourceGroupName string
    Specifies the name of the resource group the Virtual Network is located in.
    Name string
    Specifies the name of the Virtual Network.
    ResourceGroupName string
    Specifies the name of the resource group the Virtual Network is located in.
    name String
    Specifies the name of the Virtual Network.
    resourceGroupName String
    Specifies the name of the resource group the Virtual Network is located in.
    name string
    Specifies the name of the Virtual Network.
    resourceGroupName string
    Specifies the name of the resource group the Virtual Network is located in.
    name str
    Specifies the name of the Virtual Network.
    resource_group_name str
    Specifies the name of the resource group the Virtual Network is located in.
    name String
    Specifies the name of the Virtual Network.
    resourceGroupName String
    Specifies the name of the resource group the Virtual Network is located in.

    getVirtualNetwork Result

    The following output properties are available:

    AddressSpaces List<string>
    The list of address spaces used by the virtual network.
    DnsServers List<string>
    The list of DNS servers used by the virtual network.
    Guid string
    The GUID of the virtual network.
    Id string
    The provider-assigned unique ID for this managed resource.
    Location string
    Location of the virtual network.
    Name string
    ResourceGroupName string
    Subnets List<string>
    The list of name of the subnets that are attached to this virtual network.
    Tags Dictionary<string, string>
    A mapping of tags to assigned to the resource.
    VnetPeerings Dictionary<string, string>
    A mapping of name - virtual network id of the virtual network peerings.
    VnetPeeringsAddresses List<string>
    A list of virtual network peerings IP addresses.
    AddressSpaces []string
    The list of address spaces used by the virtual network.
    DnsServers []string
    The list of DNS servers used by the virtual network.
    Guid string
    The GUID of the virtual network.
    Id string
    The provider-assigned unique ID for this managed resource.
    Location string
    Location of the virtual network.
    Name string
    ResourceGroupName string
    Subnets []string
    The list of name of the subnets that are attached to this virtual network.
    Tags map[string]string
    A mapping of tags to assigned to the resource.
    VnetPeerings map[string]string
    A mapping of name - virtual network id of the virtual network peerings.
    VnetPeeringsAddresses []string
    A list of virtual network peerings IP addresses.
    addressSpaces List<String>
    The list of address spaces used by the virtual network.
    dnsServers List<String>
    The list of DNS servers used by the virtual network.
    guid String
    The GUID of the virtual network.
    id String
    The provider-assigned unique ID for this managed resource.
    location String
    Location of the virtual network.
    name String
    resourceGroupName String
    subnets List<String>
    The list of name of the subnets that are attached to this virtual network.
    tags Map<String,String>
    A mapping of tags to assigned to the resource.
    vnetPeerings Map<String,String>
    A mapping of name - virtual network id of the virtual network peerings.
    vnetPeeringsAddresses List<String>
    A list of virtual network peerings IP addresses.
    addressSpaces string[]
    The list of address spaces used by the virtual network.
    dnsServers string[]
    The list of DNS servers used by the virtual network.
    guid string
    The GUID of the virtual network.
    id string
    The provider-assigned unique ID for this managed resource.
    location string
    Location of the virtual network.
    name string
    resourceGroupName string
    subnets string[]
    The list of name of the subnets that are attached to this virtual network.
    tags {[key: string]: string}
    A mapping of tags to assigned to the resource.
    vnetPeerings {[key: string]: string}
    A mapping of name - virtual network id of the virtual network peerings.
    vnetPeeringsAddresses string[]
    A list of virtual network peerings IP addresses.
    address_spaces Sequence[str]
    The list of address spaces used by the virtual network.
    dns_servers Sequence[str]
    The list of DNS servers used by the virtual network.
    guid str
    The GUID of the virtual network.
    id str
    The provider-assigned unique ID for this managed resource.
    location str
    Location of the virtual network.
    name str
    resource_group_name str
    subnets Sequence[str]
    The list of name of the subnets that are attached to this virtual network.
    tags Mapping[str, str]
    A mapping of tags to assigned to the resource.
    vnet_peerings Mapping[str, str]
    A mapping of name - virtual network id of the virtual network peerings.
    vnet_peerings_addresses Sequence[str]
    A list of virtual network peerings IP addresses.
    addressSpaces List<String>
    The list of address spaces used by the virtual network.
    dnsServers List<String>
    The list of DNS servers used by the virtual network.
    guid String
    The GUID of the virtual network.
    id String
    The provider-assigned unique ID for this managed resource.
    location String
    Location of the virtual network.
    name String
    resourceGroupName String
    subnets List<String>
    The list of name of the subnets that are attached to this virtual network.
    tags Map<String>
    A mapping of tags to assigned to the resource.
    vnetPeerings Map<String>
    A mapping of name - virtual network id of the virtual network peerings.
    vnetPeeringsAddresses List<String>
    A list of virtual network peerings IP addresses.

    Package Details

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

    We recommend using Azure Native.

    Azure v6.10.0 published on Tuesday, Nov 19, 2024 by Pulumi