3

I created a new Azure container instance (ACI) with a new vnet and subnet by Azure CLI

I deleted ACI from Azure portal and now Im trying to delete subnet but gives me the following errors:

Failed to delete subnet 'SubnetNAme'. Error: Subnet SubnetNAme is in use by aci-network-profile-VNETNAME-SubnetNAme/eth0/ipconfigprofile and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

If I tried to access aci-network-profile-VNETNAME-SubnetNAme/eth0/ipconfigprofile, it tells me that doesnt exist this resource:

Details The resource was not found, it may have been deleted. If this was launched from a pinned tile on the dashboard, it should be removed.

exitista
  • 563
  • 2
  • 10
  • 21

4 Answers4

12

For your issue, instead of finding the aci-network-profile-VNETNAME-SubnetNAme/eth0/ipconfigprofile in the portal, you need to delete the Network Profile through Azure CLI command like this:

NETWORK_PROFILE_ID=$(az network profile list --resource-group yourResourceGroup --query [0].id --output tsv)

az network profile delete --id $NETWORK_PROFILE_ID -y

After you delete the Network Profile, then you can delete the subnet as you want. For mor details, see Delete network resources.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
0

well, i'd assume your best bet is to try and find the lingering resource and delete it (rest api would work best here, probably). another option is to recreate the ACI with the same name and remove the binding to the network before deleting it.

And your last option would be to contact support ;)

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
0

I had the same issue and me help below steps to remove aci subnet and vnet with trash container nic:

1st - find name of problem network profile by command - > az network profile list --query [].name -o tsv

2nd - create resource by terraform -> resource "azurerm_network_profile" "example" with the same network profile name and problem subnet id.

3rd - after terraform successfully create network profile, remove it by -> az network profile delete --id ...(you can find id by az network profile list --query [].id -o tsv)

4th - go to portal and change subnet delegate from container to none, after save I could delete subnet and vnet.

Roya Ghasemzadeh
  • 673
  • 5
  • 16
Alex Mayer
  • 11
  • 3
0

Below is the solution. Sometime trying just delete doesn't work. Follow the below steps and which is tested and worked for me.

NETWORK_PROFILE_ID=$(az network profile list --resource-group yourResourceGroup --query [0].id --output tsv)

az network profile delete --id $NETWORK_PROFILE_ID -y

This is a known issue and Microsoft is working on it. The workaround that worked for me is to update the containerNetworkInterfaceConfigurations property in Network profile properties to an empty list

# Get network profile ID
NETWORK_PROFILE_ID=$(az network profile list --resource-group <reource-group-name> --query [0].id --output tsv)

az resource update --ids $NETWORK_PROFILE_ID --set properties.containerNetworkInterfaceConfigurations=[]

And then deleting it works

az network profile delete --id $NETWORK_PROFILE_ID -y
Raju Rh
  • 127
  • 1
  • 9