Azure Vnet - Merge two existing subnets

Badr HOUSSNI 46 Reputation points
2021-09-29T08:46:31.627+00:00

Hi,

Due to lack of ip addresses on one of our subnets, we want to merge the full subnet with another that is not yet full.
Both subnets are on the same Vnet. The subnets ranges follow each other.
X.X.X.128/27 and X.X.X.160/27

My guess is :
1 - To unatach vm's from the second subnet (.160/27)
2 - Delete the the second subnet (.160/27)
3 - Tthen change the range of the first subnet to .128/26

Is this possible on Azure ? Is there a better way doing that ?

Here is what Microsoft says : "If no resources are deployed within the subnet, you can change the address range. If any resources exist in the subnet, you must either move the resources to another subnet, or delete them from the subnet first. The steps you take to move or delete a resource vary depending on the resource."
Link : virtual-network-manage-subnet

Thank you.

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,197 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. suvasara-MSFT 10,011 Reputation points
    2021-09-29T09:27:07.46+00:00

    @Badr HOUSSNI , Yes, your approach is right. To change subnet address range the resources, need to be deleted/migrated to another subnet. Being said that we also need to be cautious while deleting resources as there might be some components still attached to the subnet which will not allow you to delete the subnet. For example, if you have deleted a VM without deleting the NIC then the NIC turns to ghosted NIC and will not allow subnet deletion. I have done a quick repro on this,

    Subnet 1 and subnet are created out of single address range /16:

    136207-image.png

    Changing address range of subnet 1 without deleting subnet2:

    136283-image.png

    After deleting subnet 2 there will be no space for overlapping:

    136262-image.png

    ----------

    If you think your question has been answered, click "Mark as Answer" if just helped click "Vote as helpful". This can be beneficial to other community members reading this forum thread.

    0 comments No comments

  2. Badr HOUSSNI 46 Reputation points
    2021-09-29T12:34:07.387+00:00

    Hi @suvasara-MSFT ,

    Thanks for your fast response and clarification.
    I am more concern about the full subnet. You think that Azure could accept the range modification of this full subnet without unnatching ou removing all the VM's from it ?

    Thanks,
    Regards,
    Badr.