Subnet Args
Subnet in a virtual network resource. Uses Azure REST API version 2023-02-01. In version 1.x of the Azure Native provider, it used API version 2020-11-01. Other available API versions: 2019-02-01, 2019-06-01, 2019-08-01, 2020-06-01, 2022-07-01, 2023-04-01, 2023-05-01, 2023-06-01, 2023-09-01, 2023-11-01, 2024-01-01, 2024-03-01, 2024-05-01.
Example Usage
Create subnet
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var subnet = new AzureNative.Network.Subnet("subnet", new()
{
AddressPrefix = "10.0.0.0/16",
ResourceGroupName = "subnet-test",
SubnetName = "subnet1",
VirtualNetworkName = "vnetname",
});
});
package main
import (
network "github.com/pulumi/pulumi-azure-native-sdk/network/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := network.NewSubnet(ctx, "subnet", &network.SubnetArgs{
AddressPrefix: pulumi.String("10.0.0.0/16"),
ResourceGroupName: pulumi.String("subnet-test"),
SubnetName: pulumi.String("subnet1"),
VirtualNetworkName: pulumi.String("vnetname"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.Subnet;
import com.pulumi.azurenative.network.SubnetArgs;
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) {
var subnet = new Subnet("subnet", SubnetArgs.builder()
.addressPrefix("10.0.0.0/16")
.resourceGroupName("subnet-test")
.subnetName("subnet1")
.virtualNetworkName("vnetname")
.build());
}
}
Create subnet with a delegation
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var subnet = new AzureNative.Network.Subnet("subnet", new()
{
AddressPrefix = "10.0.0.0/16",
ResourceGroupName = "subnet-test",
SubnetName = "subnet1",
VirtualNetworkName = "vnetname",
});
});
package main
import (
network "github.com/pulumi/pulumi-azure-native-sdk/network/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := network.NewSubnet(ctx, "subnet", &network.SubnetArgs{
AddressPrefix: pulumi.String("10.0.0.0/16"),
ResourceGroupName: pulumi.String("subnet-test"),
SubnetName: pulumi.String("subnet1"),
VirtualNetworkName: pulumi.String("vnetname"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.Subnet;
import com.pulumi.azurenative.network.SubnetArgs;
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) {
var subnet = new Subnet("subnet", SubnetArgs.builder()
.addressPrefix("10.0.0.0/16")
.resourceGroupName("subnet-test")
.subnetName("subnet1")
.virtualNetworkName("vnetname")
.build());
}
}
Create subnet with service endpoints
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var subnet = new AzureNative.Network.Subnet("subnet", new()
{
AddressPrefix = "10.0.0.0/16",
ResourceGroupName = "subnet-test",
ServiceEndpoints = new[]
{
new AzureNative.Network.Inputs.ServiceEndpointPropertiesFormatArgs
{
Service = "Microsoft.Storage",
},
},
SubnetName = "subnet1",
VirtualNetworkName = "vnetname",
});
});
package main
import (
network "github.com/pulumi/pulumi-azure-native-sdk/network/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := network.NewSubnet(ctx, "subnet", &network.SubnetArgs{
AddressPrefix: pulumi.String("10.0.0.0/16"),
ResourceGroupName: pulumi.String("subnet-test"),
ServiceEndpoints: network.ServiceEndpointPropertiesFormatArray{
&network.ServiceEndpointPropertiesFormatArgs{
Service: pulumi.String("Microsoft.Storage"),
},
},
SubnetName: pulumi.String("subnet1"),
VirtualNetworkName: pulumi.String("vnetname"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.Subnet;
import com.pulumi.azurenative.network.SubnetArgs;
import com.pulumi.azurenative.network.inputs.ServiceEndpointPropertiesFormatArgs;
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) {
var subnet = new Subnet("subnet", SubnetArgs.builder()
.addressPrefix("10.0.0.0/16")
.resourceGroupName("subnet-test")
.serviceEndpoints(ServiceEndpointPropertiesFormatArgs.builder()
.service("Microsoft.Storage")
.build())
.subnetName("subnet1")
.virtualNetworkName("vnetname")
.build());
}
}
Import
An existing resource can be imported using its type token, name, and identifier, e.g.
$ pulumi import azure-native:network:Subnet subnet1 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
Constructors
Properties
The address prefix for the subnet.
List of address prefixes for the subnet.
Application gateway IP configurations of virtual network resource.
An array of references to the delegations on the subnet.
Array of IpAllocation which reference this subnet.
Nat gateway associated with this subnet.
The reference to the NetworkSecurityGroup resource.
Enable or Disable apply network policies on private end point in the subnet.
Enable or Disable apply network policies on private link service in the subnet.
The name of the resource group.
The reference to the RouteTable resource.
An array of service endpoint policies.
An array of service endpoints.
The name of the subnet.
The name of the virtual network.