Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
savpek committed Apr 15, 2024
2 parents b0bb7b7 + 23140c8 commit 302dc8a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Pinja.Azure.Alerts/Set-AlertRules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,24 @@ function Set-AlertRules {
}


if($PSCmdlet.ShouldProcess($ResourceGroup, "Set-AzActionGroup - azure-alerts"))
{
$alertRef = Set-AzActionGroup `
-Name "azure-alerts" `
-ResourceGroup $ResourceGroup `
-ShortName "azure-alerts" `
-Receiver $ActionGroupReceiver `
-DisableGroup:$DisableAlerts `
-WarningAction SilentlyContinue
if ($PSCmdlet.ShouldProcess($ResourceGroup, "Update-AzActionGroug - azure-alerts")) {
if (Get-AzActionGroup -Name "azure-alerts" -ResourceGroup $ResourceGroup) {
$alertRef = Update-AzActionGroup `
-Name "azure-alerts" `
-ResourceGroup $ResourceGroup `
-ShortName "azure-alerts" `
-WebhookReceiver $ActionGroupReceiver `
-Enabled:(!$DisableAlerts)
}
else {
$alertRef = New-AzActionGroup `
-Name "azure-alerts" `
-ResourceGroup $ResourceGroup `
-ShortName "azure-alerts" `
-WebhookReceiver $ActionGroupReceiver `
-Enabled:(!$DisableAlerts)
}

}
}

Expand Down

0 comments on commit 302dc8a

Please sign in to comment.