Azure Resource Manager resource group and resource deletion

This article shows how to delete resource groups and resources. It describes how Azure Resource Manager orders the deletion of resources when you delete a resource group.

How order of deletion is determined

When you delete a resource group, Resource Manager determines the order to delete resources. It uses the following order:

  1. All the child (nested) resources are deleted.

  2. Resources that manage other resources are deleted next. A resource can have the managedBy property set to indicate that a different resource manages it. When this property is set, the resource that manages the other resource is deleted before the other resources.

  3. The remaining resources are deleted after the previous two categories.

After the order is determined, Resource Manager issues a DELETE operation for each resource. It waits for any dependencies to finish before proceeding.

For synchronous operations, the expected successful response codes are:

  • 200
  • 204
  • 404

For asynchronous operations, the expected successful response is 202. Resource Manager tracks the location header or the azure-async operation header to determine the status of the asynchronous delete operation.

Deletion errors

When a delete operation returns an error, Resource Manager retries the DELETE call. Retries happen for the 5xx, 429 and 408 status codes. By default, the time period for retry is 15 minutes.

After deletion

Resource Manager issues a GET call on each resource that it tried to delete. The response of this GET call is expected to be 404. When Resource Manager gets a 404, it considers the deletion to have completed successfully. Resource Manager removes the resource from its cache.

However, if the GET call on the resource returns a 200 or 201, Resource Manager recreates the resource.

If the GET operation returns an error, Resource Manager retries the GET for the following error code:

  • Less than 100
  • 408
  • 429
  • Greater than 500

For other error codes, Resource Manager fails the deletion of the resource.


Resource Group deletion is irreversible.

Delete resource group

Use one of the following methods to delete the resource group.

Remove-AzResourceGroup -Name ExampleResourceGroup

Delete resource

Use one of the following methods to delete a resource.

Remove-AzResource `
  -ResourceGroupName ExampleResourceGroup `
  -ResourceName ExampleVM `
  -ResourceType Microsoft.Compute/virtualMachines

Required access and deletion failures

To delete a resource group, you need access to the delete action for the Microsoft.Resources/subscriptions/resourceGroups resource. You also need delete for all resources in the resource group.

For a list of operations, see Azure resource provider operations. For a list of built-in roles, see Azure built-in roles.

If you have the required access, but the delete request fails, it may be because there's a lock on the resources or resource group. Even if you didn't manually lock a resource group, it may have been automatically locked by a related service. Or, the deletion can fail if the resources are connected to resources in other resource groups that aren't being deleted. For example, you can't delete a virtual network with subnets that are still in use by a virtual machine.

Next steps