GetSubnet

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

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;

class MyStack : Stack
{
    public MyStack()
    {
        var example = Output.Create(Azure.Network.GetSubnet.InvokeAsync(new Azure.Network.GetSubnetArgs
        {
            Name = "backend",
            VirtualNetworkName = "production",
            ResourceGroupName = "networking",
        }));
        this.SubnetId = example.Apply(example => example.Id);
    }

    [Output("subnetId")]
    public Output<string> SubnetId { get; set; }
}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        example, err := network.LookupSubnet(ctx, &network.LookupSubnetArgs{
            Name:               "backend",
            VirtualNetworkName: "production",
            ResourceGroupName:  "networking",
        }, nil)
        if err != nil {
            return err
        }
        ctx.Export("subnetId", example.Id)
        return nil
    })
}
import pulumi
import pulumi_azure as azure

example = azure.network.get_subnet(name="backend",
    virtual_network_name="production",
    resource_group_name="networking")
pulumi.export("subnetId", example.id)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const example = azure.network.getSubnet({
    name: "backend",
    virtualNetworkName: "production",
    resourceGroupName: "networking",
});
export const subnetId = example.then(example => example.id);

Using GetSubnet

function getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
function  get_subnet(name=None, resource_group_name=None, virtual_network_name=None, opts=None)
func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)

Note: This function is named LookupSubnet in the Go SDK.

public static class GetSubnet {
    public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Name string

Specifies the name of the Subnet.

ResourceGroupName string

Specifies the name of the resource group the Virtual Network is located in.

VirtualNetworkName string

Specifies the name of the Virtual Network this Subnet is located within.

Name string

Specifies the name of the Subnet.

ResourceGroupName string

Specifies the name of the resource group the Virtual Network is located in.

VirtualNetworkName string

Specifies the name of the Virtual Network this Subnet is located within.

name string

Specifies the name of the Subnet.

resourceGroupName string

Specifies the name of the resource group the Virtual Network is located in.

virtualNetworkName string

Specifies the name of the Virtual Network this Subnet is located within.

name str

Specifies the name of the Subnet.

resource_group_name str

Specifies the name of the resource group the Virtual Network is located in.

virtual_network_name str

Specifies the name of the Virtual Network this Subnet is located within.

GetSubnet Result

The following output properties are available:

AddressPrefix string

(Deprecated) The address prefix used for the subnet.

AddressPrefixes List<string>

The address prefixes for the subnet.

EnforcePrivateLinkEndpointNetworkPolicies bool

Enable or Disable network policies for the private link endpoint on the subnet.

EnforcePrivateLinkServiceNetworkPolicies bool

Enable or Disable network policies for the private link service on the subnet.

Id string

The provider-assigned unique ID for this managed resource.

Name string
NetworkSecurityGroupId string

The ID of the Network Security Group associated with the subnet.

ResourceGroupName string
RouteTableId string

The ID of the Route Table associated with this subnet.

ServiceEndpoints List<string>

A list of Service Endpoints within this subnet.

VirtualNetworkName string
AddressPrefix string

(Deprecated) The address prefix used for the subnet.

AddressPrefixes []string

The address prefixes for the subnet.

EnforcePrivateLinkEndpointNetworkPolicies bool

Enable or Disable network policies for the private link endpoint on the subnet.

EnforcePrivateLinkServiceNetworkPolicies bool

Enable or Disable network policies for the private link service on the subnet.

Id string

The provider-assigned unique ID for this managed resource.

Name string
NetworkSecurityGroupId string

The ID of the Network Security Group associated with the subnet.

ResourceGroupName string
RouteTableId string

The ID of the Route Table associated with this subnet.

ServiceEndpoints []string

A list of Service Endpoints within this subnet.

VirtualNetworkName string
addressPrefix string

(Deprecated) The address prefix used for the subnet.

addressPrefixes string[]

The address prefixes for the subnet.

enforcePrivateLinkEndpointNetworkPolicies boolean

Enable or Disable network policies for the private link endpoint on the subnet.

enforcePrivateLinkServiceNetworkPolicies boolean

Enable or Disable network policies for the private link service on the subnet.

id string

The provider-assigned unique ID for this managed resource.

name string
networkSecurityGroupId string

The ID of the Network Security Group associated with the subnet.

resourceGroupName string
routeTableId string

The ID of the Route Table associated with this subnet.

serviceEndpoints string[]

A list of Service Endpoints within this subnet.

virtualNetworkName string
address_prefix str

(Deprecated) The address prefix used for the subnet.

address_prefixes List[str]

The address prefixes for the subnet.

enforce_private_link_endpoint_network_policies bool

Enable or Disable network policies for the private link endpoint on the subnet.

enforce_private_link_service_network_policies bool

Enable or Disable network policies for the private link service on the subnet.

id str

The provider-assigned unique ID for this managed resource.

name str
network_security_group_id str

The ID of the Network Security Group associated with the subnet.

resource_group_name str
route_table_id str

The ID of the Route Table associated with this subnet.

service_endpoints List[str]

A list of Service Endpoints within this subnet.

virtual_network_name str

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.