Error found while deleting subnet in Azure

Hi Team,

My Terraform is applying everything correctly but is giving an error when destroying.
The error is while trying to destroy a subnet and the error is the following:


removing Network Security Group Association from Subnet “privatesn-informatica-dbk” (Virtual Network “vnet-informatica-dbk” / Resource Group “CLOUD-POC-RG”): network.SubnetsClient
CreateOrUpdate: Failure sending request: StatusCode=0 – Original Error: Code=“NetworkSecurityGroupCannotBeRemovedDueToNipOnSubnet” Message=“Network security group cannot be removed from subnet /subscriptions/XXXXX-8906-48ad-b6eb-639bd368e7eb/resourceGroups/CLOUD-POC-RG/providers/Microsoft.Network/virtualNetworks/vnet-informatica-dbk/subnets/privatesn-informatica-dbk because it has network intent policy /subscriptions/XXXXX-8906-48ad-b6eb-639bd368e7eb/resourceGroups/CLOUD-POC-RG/providers/Microsoft.Network/networkIntentPolicies/adb-uaenorth-npip-96d694e26e1b79a7a6d1772e applied.” Details=

Any hints of what is the issue would be appreciated.

Thank you

This sounds like the subnet is in use by a service in Azure, which in turn probably set a network intent policy on it. You could use something PowerShell to remove the configuration from the subnet, that would probably help.