azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

[Feature]: Set-AzActivityLogAlert add more abilities the ARM template has. e.g. ActionGroupId.

Open AaronCreighton opened this issue 2 years ago • 5 comments

Description of the new feature

In short I would want Set-AzActivityLogAlert, to be on par with New-AzMetricAlertRuleV2Criteria. I assume once it does it will get it's own page in Azure Service Health alerts. Another way to put this would be great if Set-AzActivityLogAlert could do more of the features available in the ARM template.

One example of an instance where this is not the case is ActionGroups:

In the Portal & ARM you can assign any ActionGroup type to an Health Service Alert / ActivityLog Alert. But in powershell "ActivityLogAlertActionGroup" is the only ActionGroup type that works with Set-AzActivityLogAlert,

Another is region; According to this issue https://github.com/Azure/azure-powershell/issues/10135, impacted Region is accessible from powershell but not according to the documentation. https://docs.microsoft.com/en-us/powershell/module/az.monitor/new-azactiongroup?view=azps-7.5.0. I have yet to test this, it would be good to have, so maybe the documentation is behind.

Another is ServiceHealthServices..

Edits; I have made a number of edits to improve clarity.

Proposed implementation details (optional)

No response

AaronCreighton avatar Aug 02 '22 23:08 AaronCreighton

@VeryEarly , please check whether the latest preview version can support this scenario.

dingmeng-xue avatar Aug 03 '22 02:08 dingmeng-xue

Hi @AaronCreighton ,

do you have some action group other than "ActivityLogAlertActionGroup" need to be assign to an alert rule? please try to set the property "ActivityLogAlertActionGroup.ActionGroupId" to the resource Id of the actual action group you created.

VeryEarly avatar Aug 03 '22 02:08 VeryEarly

Hi @VeryEarly,

thank you for responding.

do you have some action group other than "ActivityLogAlertActionGroup" need to be assign to an alert rule?

My apologies I clearly needed to make it clear (added clarity). "ActivityLogAlertActionGroup" is a type of action group there are at least 2-3 types of Action groups. The type I would like to used is PSActionGroupResource.

New-AzActionGroup creates the the "ActivityLogAlertActionGroup" which is the only type that you can give the -ActionGroup parameter for Set-AzActivityLogAlert.

please try to set the property "ActivityLogAlertActionGroup.ActionGroupId" to the resource Id of the actual action group you created.

Non of the documentation for Set-AzActivityLogAlert indicates it can use the ActionGroupId as a parameter. It can be used with ARM version. I tried it anyway and got;

Line | 213 | -ActionGroupId $actionGroupId | ~~~~~~~~~~~~~~ | A parameter cannot be found that matches parameter name 'ActionGroupId'.`

It would certainly make sense that you could use ActionGroupId like you can with ARM & New-AzMetricAlertRuleV2Criteria. That way you can use both ActionGroup types.

Although a better solution would be just to have one type of ActionGroup, not sure how easily that would be.

AaronCreighton avatar Aug 03 '22 02:08 AaronCreighton

Hi @AaronCreighton ,

In your case you might want to

  1. create the actual action group by using Set-AzActionGroup
  2. get the resource Id from the action group from step 1
  3. create a ActivityLogAlertActionGroup by using New-AzActionGroup with the resource ID mentioned in step 2
  4. pass the ActivityLogAlertActionGroup created in step 3 to Set-AzActivityLogAlert

These cmdlets might look confusing, new set of cmdlets for activity log alerts with clearer parameters will be published soon.

VeryEarly avatar Aug 04 '22 09:08 VeryEarly

@VeryEarly

Thank you for this. While i would consider using it, it still leaves the other issues with the cmdlet. It is good to know a new set of cmdlets are coming. They are a bit of a confusing. The portal and cmdlet are both way behind the templates.

My solution for now was to give up on using the cmdlet and use an ARM template for now. I will be keen to update it to the cmdlet when it comes.

Same for Resource Health alerts.. Which have a template that is behind the Service Health Alerts one. With the template being behind as it is.. I didn't even loo to see if there was a cmdlet version.

AaronCreighton avatar Aug 04 '22 21:08 AaronCreighton