Deleted APIM Instance and get error ServiceAlreadyExistsInSoftDeletedState when redeploying

Was recently deploying an APIM instance using automaton and noticed error ServiceAlreadyExistsInSoftDeletedState in the output.

Full error below

Error: creating/updating Api Management: (Service Name "tamops-apim-test" / Resource Group "tamops-apim-test-rg"): apimanagement.ServiceClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="ServiceAlreadyExistsInSoftDeletedState" Message="Api service tamops-apim-test was soft-deleted. In order to create the new service with the same name, you have to either undelete the service or purge it. See"

To resolve this soft-delete with APIM resource; currently only available option is via Azure API.

I used the below to assist in resolving this error:

az rest --method delete --header "Accept=application/json" -u '{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2021-08-01-preview'

API reference used here

I thought i’d add this issue/resolution to my blog to assist others who may be facing same issue.

Thanks for reading the quick fix & hopefully assists you 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s