Error with Add-AzureRmMetricAlertRule RRS feed

  • Question

  • While attempting the creation of a metric alert for a storage account using the code below

    $windowSize = $(New-TimeSpan -Minute 5)
    $operator = 'LessThan'
    $threshold = 100
    $resourceId = '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Portal-Resources-1/providers/Microsoft.Storage/storageAccounts/xxxxxxxxxx'
    $metricName = 'Availability'
    $timeAggregationOperator = 'Total'
    $location = 'westeurope'
    $description = 'Warning'
    $resourceGroup = 'Portal-Resources-1'
    $name = 'Availability xxxxxxxxxx'

    Add-AzureRmMetricAlertRule `
        -WindowSize $windowSize `
        -Operator $operator `
        -Threshold $threshold `
        -TargetResourceId "$resourceId" `
        -MetricName $metricName `
        -TimeAggregationOperator $timeAggregationOperator `
        -Location $location `
        -Description $description `
        -ResourceGroup $resourceGroup `
        -Name $name

    I get the error stating

    Add-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: The metric with namespace '' and name 'Availability' is not supported for this resource id '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Portal-Resources-1/providers/Microsoft.Storage/storageAccounts/xxxxxxxxxx., Code: UnsupportedMetric, Status code:BadRequest, Reason phrase: Bad Request

    It seems to me that the error stems from the use of an incorrect metric name. But according to the documentation on this page https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics#microsoftstoragestorageaccounts. Availability is a supported metric for storage accounts.

    What could be causing this error?

    Wednesday, September 12, 2018 9:30 AM

All replies

  • Hi There,

    You are getting this error because availability is supported by storage metric and you need to change this line $metricName = 'Availability'since availability is supported for file, blob, queue and table with below names. In below screenshot we could see there is no metric with availability name. 

    [File] Availability
    [Queue] Availability
    [Blob] Availability
    [Table] Availability

    See below screeshot:-

    Cheers, Gourav Please remember to mark the replies as answers if it helped.

    • Edited by GouravIN Wednesday, September 12, 2018 9:55 AM
    Wednesday, September 12, 2018 9:54 AM
  • What exactly do you mean?

    $metricName = 

    Wednesday, September 12, 2018 3:12 PM