We recommend using Azure Native.
Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
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/v4/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
})
}
Example coming soon!
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)
Example coming soon!
Using getSubnet
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 getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
function getSubnetOutput(args: GetSubnetOutputArgs, opts?: InvokeOptions): Output<GetSubnetResult>def get_subnet(name: Optional[str] = None,
resource_group_name: Optional[str] = None,
virtual_network_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSubnetResult
def get_subnet_output(name: Optional[pulumi.Input[str]] = None,
resource_group_name: Optional[pulumi.Input[str]] = None,
virtual_network_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSubnetResult]func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput> Note: This function is named LookupSubnet in the Go SDK.
public static class GetSubnet
{
public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
public static Output<GetSubnetResult> Invoke(GetSubnetInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
fn::invoke:
function: azure:network/getSubnet:getSubnet
arguments:
# arguments dictionaryThe following arguments are supported:
- Name string
- Specifies the name of the Subnet.
- Resource
Group stringName - Specifies the name of the resource group the Virtual Network is located in.
- Virtual
Network stringName - Specifies the name of the Virtual Network this Subnet is located within.
- Name string
- Specifies the name of the Subnet.
- Resource
Group stringName - Specifies the name of the resource group the Virtual Network is located in.
- Virtual
Network stringName - Specifies the name of the Virtual Network this Subnet is located within.
- name String
- Specifies the name of the Subnet.
- resource
Group StringName - Specifies the name of the resource group the Virtual Network is located in.
- virtual
Network StringName - Specifies the name of the Virtual Network this Subnet is located within.
- name string
- Specifies the name of the Subnet.
- resource
Group stringName - Specifies the name of the resource group the Virtual Network is located in.
- virtual
Network stringName - Specifies the name of the Virtual Network this Subnet is located within.
- name str
- Specifies the name of the Subnet.
- resource_
group_ strname - Specifies the name of the resource group the Virtual Network is located in.
- virtual_
network_ strname - Specifies the name of the Virtual Network this Subnet is located within.
- name String
- Specifies the name of the Subnet.
- resource
Group StringName - Specifies the name of the resource group the Virtual Network is located in.
- virtual
Network StringName - Specifies the name of the Virtual Network this Subnet is located within.
getSubnet Result
The following output properties are available:
- Address
Prefix string - (Deprecated) The address prefix used for the subnet.
- Address
Prefixes List<string> - The address prefixes for the subnet.
- Enforce
Private boolLink Endpoint Network Policies - Enable or Disable network policies for the private link endpoint on the subnet.
- Enforce
Private boolLink Service Network Policies - 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
- Network
Security stringGroup Id - The ID of the Network Security Group associated with the subnet.
- Resource
Group stringName - Route
Table stringId - The ID of the Route Table associated with this subnet.
- Service
Endpoints List<string> - A list of Service Endpoints within this subnet.
- Virtual
Network stringName
- Address
Prefix string - (Deprecated) The address prefix used for the subnet.
- Address
Prefixes []string - The address prefixes for the subnet.
- Enforce
Private boolLink Endpoint Network Policies - Enable or Disable network policies for the private link endpoint on the subnet.
- Enforce
Private boolLink Service Network Policies - 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
- Network
Security stringGroup Id - The ID of the Network Security Group associated with the subnet.
- Resource
Group stringName - Route
Table stringId - The ID of the Route Table associated with this subnet.
- Service
Endpoints []string - A list of Service Endpoints within this subnet.
- Virtual
Network stringName
- address
Prefix String - (Deprecated) The address prefix used for the subnet.
- address
Prefixes List<String> - The address prefixes for the subnet.
- enforce
Private BooleanLink Endpoint Network Policies - Enable or Disable network policies for the private link endpoint on the subnet.
- enforce
Private BooleanLink Service Network Policies - 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
- network
Security StringGroup Id - The ID of the Network Security Group associated with the subnet.
- resource
Group StringName - route
Table StringId - The ID of the Route Table associated with this subnet.
- service
Endpoints List<String> - A list of Service Endpoints within this subnet.
- virtual
Network StringName
- address
Prefix string - (Deprecated) The address prefix used for the subnet.
- address
Prefixes string[] - The address prefixes for the subnet.
- enforce
Private booleanLink Endpoint Network Policies - Enable or Disable network policies for the private link endpoint on the subnet.
- enforce
Private booleanLink Service Network Policies - 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
- network
Security stringGroup Id - The ID of the Network Security Group associated with the subnet.
- resource
Group stringName - route
Table stringId - The ID of the Route Table associated with this subnet.
- service
Endpoints string[] - A list of Service Endpoints within this subnet.
- virtual
Network stringName
- address_
prefix str - (Deprecated) The address prefix used for the subnet.
- address_
prefixes Sequence[str] - The address prefixes for the subnet.
- enforce_
private_ boollink_ endpoint_ network_ policies - Enable or Disable network policies for the private link endpoint on the subnet.
- enforce_
private_ boollink_ service_ network_ policies - 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_ strgroup_ id - The ID of the Network Security Group associated with the subnet.
- resource_
group_ strname - route_
table_ strid - The ID of the Route Table associated with this subnet.
- service_
endpoints Sequence[str] - A list of Service Endpoints within this subnet.
- virtual_
network_ strname
- address
Prefix String - (Deprecated) The address prefix used for the subnet.
- address
Prefixes List<String> - The address prefixes for the subnet.
- enforce
Private BooleanLink Endpoint Network Policies - Enable or Disable network policies for the private link endpoint on the subnet.
- enforce
Private BooleanLink Service Network Policies - 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
- network
Security StringGroup Id - The ID of the Network Security Group associated with the subnet.
- resource
Group StringName - route
Table StringId - The ID of the Route Table associated with this subnet.
- service
Endpoints List<String> - A list of Service Endpoints within this subnet.
- virtual
Network StringName
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
