A criação do alerta para o AppInsights falha com "Código": "ResourceNotSupported"

Criei um App Insights na região Central dos EUA usando este script:

New-AzureRmResource -ResourceName $appInsightsName -ResourceGroupName $defaultRgName -Tag @{ Name = "AppInsightsApp"; Value = $appInsightsName} -ResourceType "Microsoft.Insights/Components" -Location $defaultLocation -PropertyObject @{"Type"="ASP.NET"} -Force

Agora estou tentando adicionar um alerta a esta instância do App Insights usando o seguinte script:

$appInsights =  Get-AzureRmResource -ResourceName $appInsightsName -ResourceGroupName $defaultRgName -ResourceType "Microsoft.Insights/Components" -Verbose

Add-AlertRule -Name "Exception Occured" -Description "Exception occured alert" -ResourceGroup $defaultRgName -ResourceId $appInsights.ResourceId -MetricName "Server Exceptions" -Operator GreaterThanOrEqual -Threshold 1 -WindowSize 00:05:00 -CustomEmails "[email protected]" -Location $defaultLocation -RuleType Metric -Verbose

E eu sempre recebendo o seguinte erro:

Add-AlertRule : ResourceNotSupported: The target resource id
'/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX/resourceGroups/RG-Dev-CentralUS/providers/Microsoft.Insights/components/testkktest-appinsights' is not supported.

Como posso corrigir esse problema?

questionAnswers(2)

yourAnswerToTheQuestion