How to purge soft-deleted Text analytics?
Asked Answered
U

4

5

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.
Universalist answered 20/5, 2021 at 12:54 Comment(4)
I cannot delete an Azure Form Recognizer resource either. I'm getting the same error. Did you figure this one out?Usk
No, it just worked when I tried it yesterday. I was able to deploy it again.Universalist
Did it take a day? I just tried it 1 day after and it's still not workingUsk
More than that. I asked question on Thursday and it probably started to work on Tuesday. I probably didn't check on Monday. When I asked Azure support on Twitter they gave me this link: learn.microsoft.com/en-us/rest/api/apimanagement/… . It's for wrong service but maybe such endpoint exists for Text analytics too.Universalist
K
8

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
Katinka answered 11/6, 2021 at 13:55 Comment(2)
There is also an az cli command for the first step: az cognitiveservices account list-deletedDanaedanaher
I just had this issue again today and it solved my problem.Universalist
U
2

I had to contact Microsoft support on this. It's still not 100% working for me yet but perhaps it might for someone else.

To purge the recently deleted resource from the undo holding area (and free up the name for new resources), use one of the following methods:

RestAPI

DELETE https://management.azure.com/subscriptions/{subscirptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroup}/deletedAccounts/{accountName}?Api-Version=2021-04-30

CLI

az resource delete /subscriptions/{subscirptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroup}/deletedAccounts/{accountName}

Powershell

Remove-AzResource -ResourceId /subscriptions/{subscirptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroup}/deletedAccounts/{accountName} -ApiVersion 2021-04-30

Usk answered 2/6, 2021 at 0:31 Comment(2)
This is how I removed it using Az PowerShell: Invoke-AzRestMethod -Path "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{rgName}/deletedAccounts/{accountName}?api-version=2021-04-30" -Method "DELETE"Colewort
az resource delete needs a --ids arg and didn't remove from the holding area az resource delete --ids /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resource-group/providers/microsoft.cognitiveservices/accounts/resource-accountKremenchug
B
1

Only this worked for me:

az cognitiveservices account purge -l northeurope -n your-service-name -g your-rg
Berkshire answered 10/2, 2022 at 15:56 Comment(0)
B
0

Thanks @chivano This worked for me Az PowerShell:

Invoke-AzRestMethod -Path "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{rgName}/deletedAccounts/{accountName}?api-version=2021-04-30" -Method "DELETE"
Bruyn answered 8/10, 2022 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.