0
votes

I previously created and subsequently deleted an Azure API Management service using Terraform. It disappeared in Azure Portal. A few hours after that, when I tried to recreate API Management with the same name, I got this error in the Azure Portal : "name already in use. Please select a different name." Also got similar error in Terraform as well.

Anyone knows why the name cannot be reused even though I am no longer seeing that name in my resource group?

1
APIM names need to be globally unique, not just within your resource group, since it is used when creating your endpoint URL. I'm assuming someone else has used your endpoint name after you deleted it.Rimaz Mohommed

1 Answers

1
votes

Check if your APIM service have been soft deleted or not. If the resource has been soft-deleted, and you want to create a new one with the same name,what you need to do is purge the resource and then recreate.

Get a soft-deleted instance by name:

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

List all soft-deleted instances for a given subscription:

GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices?api-version=2020-06-01-preview

Recover a deleted APIM instance:

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.ApiManagement/service/{apimServiceName}?api-version=2020-06-01-preview

Purge a soft-deleted APIM instance:

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