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 https://aka.ms/apimsoftdelete."

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 'https://management.azure.com/subscriptions/{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

Discover more from Thomas Thornton Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from Thomas Thornton Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading