getSubnet

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

Example Usage

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);
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)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Network.GetSubnet.Invoke(new()
{
Name = "backend",
VirtualNetworkName = "production",
ResourceGroupName = "networking",
});
return new Dictionary<string, object?>
{
["subnetId"] = example.Apply(getSubnetResult => getSubnetResult.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.LookupSubnet(ctx, &network.LookupSubnetArgs{
Name: "backend",
VirtualNetworkName: "production",
ResourceGroupName: "networking",
}, nil)
if err != nil {
return err
}
ctx.Export("subnetId", example.Id)
return nil
})
}
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.GetSubnetArgs;
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.getSubnet(GetSubnetArgs.builder()
.name("backend")
.virtualNetworkName("production")
.resourceGroupName("networking")
.build());
ctx.export("subnetId", example.id());
}
}
variables:
example:
fn::invoke:
function: azure:network:getSubnet
arguments:
name: backend
virtualNetworkName: production
resourceGroupName: networking
outputs:
subnetId: ${example.id}

API Providers

This data source uses the following Azure API Providers:

  • Microsoft.Network: 2024-05-01

Return

A collection of values returned by getSubnet.

Parameters

argument

A collection of arguments for invoking getSubnet.


suspend fun getSubnet(name: String, resourceGroupName: String, virtualNetworkName: String): GetSubnetResult

Return

A collection of values returned by getSubnet.

Parameters

name

Specifies the name of the Subnet.

resourceGroupName

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

virtualNetworkName

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

See also


suspend fun getSubnet(argument: suspend GetSubnetPlainArgsBuilder.() -> Unit): GetSubnetResult

Return

A collection of values returned by getSubnet.

Parameters

argument

Builder for com.pulumi.azure.network.kotlin.inputs.GetSubnetPlainArgs.

See also