A while ago, API Management received a default soft-delete feature. This is very handy for mission-critical workloads, because it protects against accidental removal. However, in development environments, this causes often friction, because you cannot toggle the soft-delete feature. This means that often you need to explicitly purge a soft-deleted API Management instance. This blog explains how you can do this.
The documentation
The documentation is quite basic. It states:
DELETE https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2021-08-01
Two possible ways
Use Azure CLI
The easiest way is to work fully with Azure CLI (thanks Geert Baeke for the tip!)>
- Log in to Azure with Azure CLI, using an account that has sufficient access
az login
- Replace the {placeholders} in the URL and execute this command:
az rest --method delete --url "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2021-08-01"
Use Postman
- Open Postman or any other HTTP client
- Set the HTTP Method to DELETE
- Replace the {placeholders} in the URL with the correct values
- Log in to Azure with Azure CLI, using an account that has sufficient access
az login
- Request a JWT token and copy the value of the accessToken
az account get-access-token
- In Postman, add a new HTTP Header for the authentication
Authorization: Bearer <accessToken>
- Now you can successfully purge the soft-deleted API Management instance
I hope this blog helped you to purge your API Management instance!
Cheers
Toon