Skip to content

Virtual Network module fails when deploying to a network that has existing workloads in it #1111

@ahmadabdalla

Description

@ahmadabdalla

If the virtual network already contains workloads in it, attempting to redeploy the vnet results in failure.

Description

The reason is that we are defining the subnet resources outside of the virtual network resource, and that tries to delete all the subnets in the virtual network, which fails. Although we are defining the subnets as a child resource. This doesn't work with this type of resource as all the subnets need to be in the VNET resource.

This was discovered when running the dependency pipeline (in a fork) and had the following error:

     | 3:53:28 PM - The deployment 'virtualNetworks-20220309T1503008054Z' failed with error(s). Showing 1 out of 1 error(s).
Status Message: Subnet crawl-az-subnet-x-001 is in use by /subscriptions/20d6fbfe-b049-471c-95af-1369d14d0d45/resourceGroups/validation-rg/providers/Microsoft.Network/networkInterfaces/adp-crawl-vm-01-nic-01/ipConfigurations/ipconfig01 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet. (Code: InUseSubnetCannotBeDeleted)
CorrelationId: b833c292-0cba-4699-91b1-3213358bbb78

Additional references.

Looking up this issue, I can see it already raised here Azure/bicep-types-az#1687 with the recommendation to have it in the single vnet resource Azure/bicep-types-az#1687 and this is also still an open item here Azure/azure-quickstart-templates#2786

Steps to reproduce

  1. Create a VNET using the module
  2. Create a workload in that VNET
  3. Redeploy the VNET module

Screenshots

During a deployment, this is what happens inside the VNET (when it doesn't have resources)
image

However, this does solve it (AS A WORKAROUND) and a roll back to the PR #1081
image

We need to discuss on:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions