Skip to content

Commit

Permalink
Merge pull request #3 from by-pinja/feat/fixes-to-work-with-az.monito…
Browse files Browse the repository at this point in the history
…r.5.x

Updated methods to work with new az module
  • Loading branch information
savpek authored Mar 28, 2024
2 parents fe8be2b + 6128a5a commit 23140c8
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 23140c8

Please sign in to comment.