Search code examples
azureazure-resource-managerazure-cognitive-services

How to purge soft-deleted Text analytics?


To test ARM templates we first deploy them on test resource group. At 7PM those resource groups are automatically deleted. Yesterday it was working fine and today I can no longer deploy to the same test resource group name. I have not changed templates for a long time.

I'm not able to find this soft-deleted service anywhere in Azure Portal and don't know how to purge it.

14:43:17 - Error: Code=FlagMustBeSetForRestore; Message=An existing resource with ID
     | '/subscriptions/GUID/resourceGroups/myRG/providers/Microsoft.CognitiveServices/accounts/my-ta-zneztme4oqjb2' has been
     | soft-deleted. To restore the resource, you must specify 'restore' to be 'true' in the property. If you don't want to restore existing resource, please purge it first.

Solution

  • Here a link to the rest endpoints you can call against cognitive services

    There is an endpoint to list the deleted cognitive services which you can call like this:

    az rest --method get --header 'Accept=application/json' -u 'https://management.azure.com/subscriptions/$SubscriptionId/providers/Microsoft.CognitiveServices/deletedAccounts?api-version=2021-04-30'
    

    It returns a json structure listing of the deleted cognitive services. Each deleted service has an id property, which is the thing you pass to the delete method:

    az resource delete --ids $id