无法在 PowerShell 中删除 Microsoft.Insights/components 资源
Cannot delete Microsoft.Insights/components resource in PowerShell
我以前问过这个问题,但发现我得到的答案并没有解决整个问题。
在我的 PowerShell 脚本中,我部署了一个 Web 应用程序以及 Application Insights 资源(包括 Microsoft.Insights/components 资源)。在另一个脚本中,我从资源组中删除了这些相同的资源,但保留了组名称,因为我不是该组中唯一的工作人员。
当我尝试删除资源时出现了问题。无论我选择的顺序如何,当我执行命令时:
Remove-AzureRmResource -ResourceId "/subscriptions/<subscriptionId>/resourceGroups/TestRG/providers/Microsoft.Insights/components/WA-Stag-API-EMEA-zgqmgcwnigknu"
我立即得到错误:
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
但是,如果我再次尝试 相同的命令,资源将被成功删除,并且在 Azure 门户上不再可见。我真的很想知道为什么会发生这种情况以及如何解决正在发生的问题。该错误似乎很长且含糊不清,所以我现在不知道去哪里寻找补救措施。
编辑
这是我用来部署资源的 ARM 模板:
https://jsonblob.com/1b4ddaa4-6cef-11e7-a38a-2184080e56f4
当网络应用程序或其他资源使用 Insights 时,您将收到错误日志。我检查了你的模板,对于开发环境,我建议你不要在你的网络应用程序和 Insights 中使用相同的名称。您最好为您的 Insights 使用动态名称。它可以确保它不被其他网络应用程序使用。
我以前问过这个问题,但发现我得到的答案并没有解决整个问题。
在我的 PowerShell 脚本中,我部署了一个 Web 应用程序以及 Application Insights 资源(包括 Microsoft.Insights/components 资源)。在另一个脚本中,我从资源组中删除了这些相同的资源,但保留了组名称,因为我不是该组中唯一的工作人员。
当我尝试删除资源时出现了问题。无论我选择的顺序如何,当我执行命令时:
Remove-AzureRmResource -ResourceId "/subscriptions/<subscriptionId>/resourceGroups/TestRG/providers/Microsoft.Insights/components/WA-Stag-API-EMEA-zgqmgcwnigknu"
我立即得到错误:
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
但是,如果我再次尝试 相同的命令,资源将被成功删除,并且在 Azure 门户上不再可见。我真的很想知道为什么会发生这种情况以及如何解决正在发生的问题。该错误似乎很长且含糊不清,所以我现在不知道去哪里寻找补救措施。
编辑 这是我用来部署资源的 ARM 模板: https://jsonblob.com/1b4ddaa4-6cef-11e7-a38a-2184080e56f4
当网络应用程序或其他资源使用 Insights 时,您将收到错误日志。我检查了你的模板,对于开发环境,我建议你不要在你的网络应用程序和 Insights 中使用相同的名称。您最好为您的 Insights 使用动态名称。它可以确保它不被其他网络应用程序使用。