Garrett Vlieger
Garrett Vlieger

Reputation: 9494

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?

Upvotes: 4

Views: 770

Answers (1)

Aatif Akhter
Aatif Akhter

Reputation: 2206

Hi Garrett sometime back I had created same kind of stuff without any issues. Please have a look on this link-

http://blogs.technet.com/b/keithmayer/archive/2014/11/08/scripts-to-tools-automate-monitoring-alert-rules-in-microsoft-azure-with-powershell-and-the-azure-service-management-rest-api.aspx

Upvotes: 1

Related Questions