Any possible way to send custom JSON payload from Alert nowdays?

Rupec Stanislav 1 Reputation point
2022-03-31T14:00:44.85+00:00

Hello all,
I am trying to find some way how to add custom JSON payload to the Azure Alert as Custom Actions containing that option were removed from the Alert wizard during Nov 2021. I already found and tried this workaround but when I create it via PS I am not able to see it in the Azure portal I am able only to list it via Get-AzScheduledQueryRule. Now I am not sure if this workaround was also blocked by MS or I have something wrong with my code.

PS code:

$source = New-AzScheduledQueryRuleSource -Query 'AzureDiagnostics| where ResourceProvider  == "MICROSOFT.LOGIC"| where Category == "WorkflowRuntime" | where status_s == "Failed"| where code_s != "NotFound"| where resource_workflowName_s contains "KEYWORD"| where OperationName has "workflowActionCompleted" or OperationName has "workflowTriggerCompleted"| summarize AggregatedValue =  count() by bin(TimeGenerated,6m),resource_workflowName_s' -DataSourceId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg"  
$schedule = New-AzScheduledQueryRuleSchedule -FrequencyInMinutes 5 -TimeWindowInMinutes 5  
$metricTrigger = New-AzScheduledQueryRuleLogMetricTrigger -ThresholdOperator "GreaterThan" -Threshold 0 -MetricTriggerType "Consecutive" -MetricColumn "resource_workflowName_s"  
$triggerCondition = New-AzScheduledQueryRuleTriggerCondition -ThresholdOperator "GreaterThan" -Threshold 0 -MetricTrigger $metricTrigger  
$aznsActionGroup = New-AzScheduledQueryRuleAznsActionGroup -ActionGroup "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/microsoft.insights/actionGroups/myactionsgroup"  
$alertingAction = New-AzScheduledQueryRuleAlertingAction -AznsAction $aznsActionGroup -Severity "3" -Trigger $triggerCondition  
New-AzScheduledQueryRule -ResourceGroupName "my-rg" -Location "westeurope" -Action $alertingAction -Enabled $false -Description "test script rule" -Schedule $schedule -Source $source -Name "Test Alert rule by script"   

Result of Get-AzScheduledQueryRule:
188812-image.png

Azure portal:
188831-image.png

Thank you in advance for any help!
Stanislav

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,645 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rupec Stanislav 1 Reputation point
    2022-04-01T09:01:29.203+00:00

    Today I deleted Alert rule via Remove-AzScheduledQueryRule and create it again under a different name but I am still not able to see it in Alert rules, but by modification of URL of one of the already existing alert rules properties I was able to open its properties but I am still confused how I am missing it in alert rules when it is there:
    189112-image.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.