简体   繁体   中英

Error adding Alert Rule to Azure Cloud Service

I've created a script to add alert rules to several Azure resources (web apps, SQL databases, and cloud services). Everything works except for creating the cloud service alerts which returns an error:

Add-AlertRule : ResourceProviderNotSupported: The resource provider 'Microsoft.ClassicCompute' is not supported.

This is the script I'm using to add the rule:

$cloudServices = Get-AzureResource -ResourceType "Microsoft.ClassicCompute/domainNames" -ResourceGroupName $resourceGroup

Foreach ($cloudService in $cloudServices)
{
    # Cloud Service - CPU Percentage
    Add-AlertRule `
      -RuleType Metric `
      -Name "CPU Percentage (Cloud Service)" `
      -Location $cloudService.Location `
      -ResourceGroup $cloudService.ResourceGroupName `
      -Operator GreaterThan `
      -Threshold 75 `
      -WindowSize 01:00:00 `
      -ResourceId $cloudService.ResourceId `
      -MetricName "Percentage CPU" `
      -TimeAggregationOperator Average `
      -SendToServiceOwners
}

I've tried other using a different ResourceType parameter to target the role instead of the cloud service, but that doesn't work either.

Has anyone had any experience scripting these cloud service alerts successfully?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM