Hello @Wasim Al Sabbouh , Welcome to the Microsoft Q&A forum.
As I understand from the question above you are unable to delete a public IP prefix using both AZ CLI and Terraform and you are receiving an InternalServerError. You can try below mentioned steps and see if this helps resolve the issue.
- As documented here you can't delete a prefix if any addresses within it are assigned to public IP address resources associated to a resource. Dissociate all public IP address resources that are assigned IP addresses from the prefix first. This is the most common issue if you are unable to delete any public IP prefix. Although when deleting such public IP prefix we get an intelligent error like
InUsePublicIpPrefixCannotBeDeleted(as shown in screenshot below), but it might help if you can check if the Public IPs are still associated with any resource like a VM, Azure Firewall, any DNAT rule etc.
- If any of the IP's are not associated with any resource and as the error received is not helpful. Can you try deleting the IP prefix again and see if that resolves this issue as this might be a transient error.
- If this does not resolve the issue, it might be helpful if you could create a support ticket in this case. Please let me know if you do not have support plan.
Hope this helps! Thank you!