Imagine Phantoms: When Soft-Deleted API Management Breaks Provisioning
I ran into an issue provisioning API Management, and it was one of those situations where everything looked like a normal deployment problem — but it wasn’t. The resource wouldn’t provision cleanly, and after a bit of time spent retrying and double-checking the usual suspects, I ended up going through the trouble of filing a support ticket.
The frustrating part was that nothing about the failure initially screamed “soft delete.” It just felt like Azure was refusing to cooperate.
What Was Actually Going On
The issue turned out to be that an API Management instance with the same name already existed in a soft-deleted state. In other words, Azure still had a record of the service name, even though it didn’t show up the way you’d expect when you’re scanning your active resources.
That meant any attempt to provision a new API Management service with that same name would collide with the soft-deleted resource and fail.
The Fix
Once you suspect soft delete, the fix is straightforward — but only if you’re looking in the right place first.
The first step is to make sure you’re operating in the correct subscription context. If you’re in the wrong subscription, you can waste a lot of time because your commands will return empty results even though the soft-deleted resource exists somewhere else.
After confirming you’re in the right subscription, run this command:
az apim deletedservice list
That will show whether you have an API Management instance sitting in soft delete. Once you verify that the instance is there, you can purge it and fully release the name:
az apim deletedservice purge --location westus3 --service-name apim-foobar
In my case, purging the deleted service immediately cleared the blockage and provisioning worked normally afterward.
Conclusion
This was a good reminder that “resource already exists” doesn’t always look like “resource already exists,” especially with services like API Management where soft delete can silently hold onto names. This is definitely an area where I’d look for the azurerm Terraform provider to provide better transparency in handling this friction.
If you’re stuck provisioning APIM and nothing else makes sense, checking for a soft-deleted instance is a quick step that can save a lot of unnecessary churn — support ticket included.