question

WilliamAWang-0291 avatar image
0 Votes"
WilliamAWang-0291 asked WilliamAWang-0291 commented

Can not modify or delete the subnet

When I try to modify the delegate of subnet or delete the subnet, the error will occur: Failed to save subnet 'Public'. Error: 'Subnet VNet/Public requires any of the following delegation(s) [Microsoft.ContainerInstance/containerGroups] to reference service association link /subscriptions/xxx-xxx/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/virtualNetworks/VNet/subnets/Public/serviceAssociationLinks/acisal.'
It used to serving a container instance, but recently the CI has been migrated to kubernetes and the original one has deleted. But the related subnet can't modify.

azure-virtual-networkazure-container-instances
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

suvasara-MSFT avatar image
0 Votes"
suvasara-MSFT answered WilliamAWang-0291 commented

@WilliamAWang-0291, This is expected due to the orphaned service association link. Here are the commands you can try to delete the subnet,

   # log into Azure
     az login
         
     # Set the name of your resource group
     RES_GROUP=TestRG
             
     # Get network profile ID
     NETWORK_PROFILE_ID=$(az network profile list --resource-group $RES_GROUP --query [0].id --output tsv)
             
     # Delete the network profile
      az network profile delete --id $NETWORK_PROFILE_ID -y
                
     # Get the service association link (SAL) ID
     SAL_ID=$(az network vnet subnet show --resource-group $RES_GROUP --vnet-name TestRGVirtualNetwork --name TestRGSubnet1 --query id --output tsv)/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default
              
     # Delete the default SAL ID for the subnet
     az resource delete --ids $SAL_ID --api-version (The api version of the resource (omit for the latest stable version))
         
     # Delete the subnet delegation to Azure Container Instances
     az network vnet subnet update --resource-group $RES_GROUP --vnet-name TestRGVirtualNetwork --name TestRGSubnet1 --remove delegations 0
        
     # Delete the subnet
     az network vnet subnet delete --resource-group $RES_GROUP --vnet-name TestRGVirtualNetwork --name TestRGSubnet1
         
     # Delete virtual network
     az network vnet delete --resource-group $RES_GROUP --name TestRGVirtualNetwork



Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Looks good thanks

0 Votes 0 ·