Subnets - az network vnet subnet

Manage subnets in an Azure Virtual Network.

Commands

az network vnet subnet create Create a subnet and associate an existing NSG and route table.
az network vnet subnet delete Delete a subnet.
az network vnet subnet list List subnets.
az network vnet subnet show Show details of a subnet.
az network vnet subnet update Update a subnet.

az network vnet subnet create

Create a subnet and associate an existing NSG and route table.

az network vnet subnet create --address-prefix
--name
--resource-group
--vnet-name
[--network-security-group]
[--private-access-services]
[--route-table]

Examples

Create new subnet attached to an NSG with a custom route table.

az network vnet subnet create -g MyResourceGroup --vnet-name MyVnet -n MySubnet --address-prefix 10.0.0.0/24 --network-security-group MyNsg --route-table MyRouteTable

Required Parameters

--address-prefix

The address prefix in CIDR format.

--name -n

The subnet name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--vnet-name

The virtual network (VNet) name.

Optional Parameters

--network-security-group

Name or ID of network security group to associate with the subnet.

--private-access-services

Space separated list of services for which to allow private access to this subnet.

value from: az network list-private-access-services
--route-table

Name or ID of a route table to associate with the subnet.

az network vnet subnet delete

Delete a subnet.

az network vnet subnet delete --name
--resource-group
--vnet-name

Required Parameters

--name -n

The subnet name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--vnet-name

The virtual network (VNet) name.

az network vnet subnet list

List subnets.

az network vnet subnet list --resource-group
--vnet-name

Required Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--vnet-name

The virtual network (VNet) name.

az network vnet subnet show

Show details of a subnet.

az network vnet subnet show --name
--resource-group
--vnet-name
[--expand]

Required Parameters

--name -n

The subnet name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--vnet-name

The virtual network (VNet) name.

Optional Parameters

--expand

Expands referenced resources.

az network vnet subnet update

Update a subnet.

az network vnet subnet update --name
--resource-group
--vnet-name
[--add]
[--address-prefix]
[--network-security-group]
[--private-access-services]
[--remove]
[--route-table]
[--set]

Required Parameters

--name -n

The subnet name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--vnet-name

The virtual network (VNet) name.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .

--address-prefix

The address prefix in CIDR format.

--network-security-group

Attach with existing network security group, both name or id are accepted. Use empty string "" to detach it.

--private-access-services

Space separated list of services for which to allow private access to this subnet.

value from: az network list-private-access-services
--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--route-table

Name or ID of a route table to associate with the subnet.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.