Remove-AzureRmVirtualNetworkSubnetConfig
Removes a subnet configuration from a virtual network.
Warning
The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.
Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.
Syntax
Remove-AzureRmVirtualNetworkSubnetConfig
[-Name <String>]
-VirtualNetwork <PSVirtualNetwork>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Remove-AzureRmVirtualNetworkSubnetConfig cmdlet removes a subnet from an Azure virtual network.
Examples
1: Remove a subnet from a virtual network and update the virtual network
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet
-AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix
"10.0.2.0/24"
$virtualNetwork = New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName
TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet
Remove-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -VirtualNetwork
$virtualNetwork
$virtualNetwork | Set-AzureRmVirtualNetwork
This example creates a resource group and a virtual network with two subnets. It then uses the Remove-AzureRmVirtualNetworkSubnetConfig command to remove the backend subnet from the in-memory representation of the virtual network. Set-AzureRmVirtualNetwork is then called to modify the virtual network on the server side.
Parameters
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
Specifies the name of the subnet configuration to remove.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VirtualNetwork
Specifies the VirtualNetwork object that contains the subnet configuration to remove.
Type: | PSVirtualNetwork |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
Parameters: VirtualNetwork (ByValue)