Can not modify or delete the subnet

William A Wang 236 Reputation points
2021-09-29T09:20:35.143+00:00

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 Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
643 questions
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,167 questions
0 comments No comments
{count} votes

Accepted answer
  1. suvasara-MSFT 10,011 Reputation points
    2021-09-29T09:47:35.93+00:00

    @William A Wang , 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.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful