Background, I am testing deployment of Alerts Rules, Conditions and Action Groups. I have started with 3 alerts.
Issue,
Here is an example:
Here is a dev alert rule and condition
Here is the test alert rule and condition
Here is the core deployment code:
Try {
$dim1 = New-AzMetricAlertRuleV2DimensionSelection -DimensionName $dimentionName -ValuesToInclude $dimentionValue
$condition = New-AzMetricAlertRuleV2Criteria `
-MetricName $metricName `
-MetricNameSpace $metricNameSpace `
-TimeAggregation $timeAggregation `
-Operator $operator `
-Threshold $threshold `
-DimensionSelection $dim1
}
catch {
Write-Output "${alertName}: set condition Error"
}
Try {
Add-AzMetricAlertRuleV2 `
-Name $alertName `
-resourceGroupName $mgnResourceGroup `
-WindowSize $aggregationGranularity `
-Frequency $frequencyofEvaluation `
-TargetresourceId $targetResourceId `
-Condition $condition `
-AutoMitigate $autoMitigate `
-ActionGroupId $actionGroupId `
-Description $alertDescription `
-Severity $severity `
}
catch
{
Write-Output "${alertName}: add alert Error"
}
Edit 1 Additional research:
Here is the comparison of the base ARM templates.
Thank you for reading.
I appreciate all thoughts and ideas about the cause.
This is an access issues. I could not see alert information as I did not have permission in test to see the metrics on the target resource.
To fix, add either reader access to the resource group or "monitoring reader" access to the resource group.