I had asked this question once before, but realized the answer I got did not fix the entire issue.
In my PowerShell script I have deployed a web app along with Application Insights resources to go along with it (including the Microsoft.Insights/components resource). In another script I am removing these same resources from a Resource Group, but retaining the group name as I am not the only one working in this group.
My issue arises when I try to delete resources. Regardless of the order I choose to do so in, when I execute the command:
Remove-AzureRmResource -ResourceId "/subscriptions/<subscriptionId>/resourceGroups/TestRG/providers/Microsoft.Insights/components/WA-Stag-API-EMEA-zgqmgcwnigknu"
I immediately get the error:
Remove-AzureRmResource : {"code":"Message: {\"Errors\":[\"One of the specified pre-condition is not met\"]}","message":"Message: {\"Errors\":[\"One of the specified pre-condition is not met\"]}\r\nActivityId: 845b19fa-b6b4-4952-9b62-75bfc6e98646, Request URI: /apps/1921ec42-1c88-4fdd-8d6c-78646cba4b15/services/a32b484a-6ee1-4ad7-ab43-4e9 d57bb0b81/partitions/fab8c193-3ec3-45e8-b7a6-0e21d1e071da/replicas/131441657816991616p","innererror":{"diagnosticcontext":"597ea546-7625-474d-b27f-560a1140a652","time":"2017- 07-18T19:41:25.3734216Z"}} At line:1 char:1 + Remove-AzureRmResource -ResourceId "/subscriptions/ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Remove-AzureRmResource], ErrorResponseMessageException + FullyQualifiedErrorId : Conflict,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdlet
However, if I attempt the same command again, the resource is successfully removed and is no longer visible on the Azure Portal. I would really love to know why this is happening and how to mend the issue that is occurring. The error seems quite long and vague, so I'm at a loss right now on where to even look for a remedy.
EDIT Here's the ARM template I am using to deploy my resources: https://jsonblob.com/1b4ddaa4-6cef-11e7-a38a-2184080e56f4
Enable client side monitoring
. I get the same error log. Also, I test remove web app firstly by usingRemove-AzureRmResource -ResourceId "/subscriptions/****-****-****/resourceGroups/shuitest123/providers/Microsoft.Web/sites/WA-QA-CIMS-API-NAA-fo7xm45lirlic"
, then delete Insights `Remove-AzureRmResource -ResourceId I don't meet the error log. – Shui shengbao<Your web app>--><Development Tools>--><Extensions>
. – Shui shengbao