Azure-docs: How to edit alert action groups / notifications?

Created on 18 Feb 2019  Â·  11Comments  Â·  Source: MicrosoftDocs/azure-docs

How does a user edit alert action groups so that notifications/emails can be generated for active alerts?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Azure-Monitosvc cxp product-feedback product-question triaged

Most helpful comment

@kprpg Hi, here the script you can use to apply Action Group to all VMs in the tennant:

<#

  1. install Choco
  1. Install ARM client
    https://github.com/projectkudu/armclient

  2. create action group and put it's ID in the $payload

  3. run the script

    >

$payload = "{'properties':{'ActionGroupResourceIds':['/subscriptions/Subscription ID where you have your Action Group/resourceGroups/Name of Resource Group where you have you Action Group/providers/microsoft.insights/actionGroups/Name of your action group']}}"

$Subscriptions=Get-AzSubscription
foreach($Sub in $Subscriptions){

Set-AzContext -SubscriptionId $Sub.Id | out-null

$AllVMs = Get-azvm -Status | ? {$_.PowerState -match "running"}

foreach ($VM in $AllVMs){

$SUb.Name, $VM.ResourceGroupName, $VM.Name
$Path = "https://management.azure.com" + $VM.id + "/providers/Microsoft.WorkloadMonitor/notificationSettings/default?api-version=2018-08-31-preview"

armclient PUT $Path $payload

}
}

All 11 comments

@jaredmny Thanks for the feedback! We are currently investigating and will update you shortly.

Same question, how do I use the alerts generated by this solution to trigger emails/notifications with action groups. It looks like the alerts can only be consumed from within the portal today, unless I've missed something.

@MGoedtel Does this preview solution currently supports email alerts via action groups? if yes, do we have steps to generate email alerts from this solution?

@jaredmny & @marcusclayton, Did some research on this AFAIK the preview solution currently doesnt support email notifications via action groups. I recommend sharing this valuable product feedback directly with the Azure monitor feature team for consideration in future release

@MGoedtel - FYI.

@jaredmny & @marcusclayton - The solution only supports action groups that are configured with email/sms notification and you can only configure it via the Workload Insights API for notification settings - (https://docs.microsoft.com/en-us/rest/api/monitor/microsoft.workloadmonitor/notificationsettings/update.

Here is an example:

armclient PUT "subscriptions/Subscription_Name/resourceGroups/Resource_Group_Name/providers/Microsoft.Compute/virtualMachines/VM_Name/providers/Microsoft.WorkloadMonitor/notificationSettings?api-version=2018-08-31-preview"  @payload.json (JSON Script)

Payload json script contains the resource ID of the action group:

{
"ActionGroupResourceIds": [“Action_Group_Resource_ID"]
}

The topic of alerting with the Health feature in the docs is something that we are working to address and apologize for the frustration. #in-progress

@MGoedtel Thanks for the workaround. Looks like we'll need to do this for each VM individually, right? I'll plan to test this method out.

@marcusclayton - Yes, I'm afraid that is the case. Also I am providing an updated example on how to use the API based on testing I did last night after finding the information I was provided wasn't 100% accurate -
$payload = "{'properties': { 'actionGroupResourceIds': '/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/microsoft.insights/actionGroups/ActionGroupName'} }"
armclient PUT https://eastus2euap.management.azure.com/subscriptions/subscriptionID/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/VMName/providers/Microsoft.WorkloadMonitor/notificationSettings/default?api-version=2018-08-31-preview $payload

The VM's must be running in order for this action to work successfully. I found this method easier than creating a json file for the action group name.

Hope that helps.

please-close as I have answered the question and recently updated the AzMon for VMs Health article to detail this scenario and steps to configure in detail.

It looks like this has to be done for each individual VM onbe by one by looping through. Is there a way to do this for (a) all VMs in a subscription or (b) within a Resource Group?

@kprpg - With the preview release, you have to do this per VM resource by default. It would require a custom script to loop through each VM resource that is in-scope (which would be all VMs reporting to the workspace tied to AzMon for VMs) if you want notifications from all VMs. Work is in progress to fully integrate with Azure Alerting to avoid this but I don't have an ETA at this time. #please-close.

@kprpg Hi, here the script you can use to apply Action Group to all VMs in the tennant:

<#

  1. install Choco
  1. Install ARM client
    https://github.com/projectkudu/armclient

  2. create action group and put it's ID in the $payload

  3. run the script

    >

$payload = "{'properties':{'ActionGroupResourceIds':['/subscriptions/Subscription ID where you have your Action Group/resourceGroups/Name of Resource Group where you have you Action Group/providers/microsoft.insights/actionGroups/Name of your action group']}}"

$Subscriptions=Get-AzSubscription
foreach($Sub in $Subscriptions){

Set-AzContext -SubscriptionId $Sub.Id | out-null

$AllVMs = Get-azvm -Status | ? {$_.PowerState -match "running"}

foreach ($VM in $AllVMs){

$SUb.Name, $VM.ResourceGroupName, $VM.Name
$Path = "https://management.azure.com" + $VM.id + "/providers/Microsoft.WorkloadMonitor/notificationSettings/default?api-version=2018-08-31-preview"

armclient PUT $Path $payload

}
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments

Ponant picture Ponant  Â·  3Comments

DeepPuddles picture DeepPuddles  Â·  3Comments

jamesgallagher-ie picture jamesgallagher-ie  Â·  3Comments

behnam89 picture behnam89  Â·  3Comments