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.
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
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
Only this worked for me:
az cognitiveservices account purge -l northeurope -n your-service-name -g your-rg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With