Eduard Keilholz

Hi, my name is Eduard Keilholz. I'm a Microsoft developer working at 4DotNet in The Netherlands. I like to speak at conferences about all and nothing, mostly Azure (or other cloud) related topics.
LinkedIn | Twitter | Mastodon | Bsky


I received the Microsoft MVP Award for Azure

Eduard Keilholz
HexMaster's Blog
Some thoughts about software development, cloud, azure, ASP.NET Core and maybe a little bit more...

Purging Deleted Services in Azure with Postman

The ARM (Azure Resource Manager) controls all your resource deployments in Azure. It performs a couple of checks and then hands out work to a resource provider that will do the actual work. For each resource, you need to specify an API version. This API version is the version of the resource provider you communicate with. Although it sounds obvious to always take the latest version, sometimes it’s not. One example is API Management.

The problem

If you pick the latest version of the API Management resource provider and provision an instance of API Management, it will come with delete protection. This means that once deleted, the service is not actually gone, but soft-deleted. You can recover it to get the service back or purge it to definitely get rid of it. However, this purge action is not supported in the Azure Portal (just yet). For some services, it is, like Azure Key Vault, but for some services, you need to do some magic and this magic can be found right here ;)

Removing the service

For this API Management example, I’m going to show you how to use Postman to make a delete call that purges your resource. Let’s check the docs and find out what call you need to make.

Ok, so you need to know your subscription ID (which is a GUID), your location (in my case westeurope), and the name of your API Management instance. Then you need to make a delete request to this URL:

https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2021-08-01

Authenticating

You cannot make this call without being authenticated. I used the Azure CLI to generate an access token. First, you need to log in, then you need to select the correct subscription (if the correct subscription is not already selected), and then you need to generate an access token.

az login
az account set --subscription {subscriptionId}
az account get-access-token --resource https://management.azure.com/

This prints out a brand new access token that you can use to make the call. Copy the content of the access token (starting with ey) and start Postman.

Making the call

Now in postman, open a new request tab and set the verb to DELETE. The creates a delete request. Then navigate to the Authorization tab. In the Type box, select Bearer Token. On the right, you’ll see a textbox appear called Token. Paste your access token (ey....) into this textbox.

Then copy the adjusted delete URL you created earlier and paste this in the address bar. Click the ‘Send’ button at the end of the address bar to make the delete request.

Purging services with Postman

If everything runs correctly, you will receive a 202 (Accepted) back with some purge and deletion data in the payload.

You are not limited to API Management

There are more services with this very same problem, it’s not only API Management. You can adjust the URL of your DELETE request so it contains the correct provider name if you want to purge different services. If you want to discover the names of resource providers and resources, navigate to the Azure Portal and use the Resource Explorer as described here.