Skip to content

Commit af0071b

Browse files
AvivskieVeryEarly
andauthored
Fix update activity log alert rule when using ObjectInput from the pipe (#12111)
* remove duplication of action/conditions. this fixes the update alert rule issue. * correct fix - convert the type * Update ChangeLog.md Co-authored-by: Aviv Haddad <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent d98850b commit af0071b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Monitor/Monitor/ActivityLogAlert/SetAzureRmActivityLogAlertCommand.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected override void ProcessRecordInternal()
150150
resourceGroupName: out resourceGroupName,
151151
activityLogAlertName: out activityLogAlertName);
152152

153-
requestBody = this.UpdateActivityLogAlertResource(this.InputObject);
153+
requestBody = this.UpdateActivityLogAlertPsResource(this.InputObject);
154154
}
155155
else if (this.MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(this.ResourceId))
156156
{
@@ -205,6 +205,23 @@ protected override void ProcessRecordInternal()
205205
}
206206
}
207207

208+
private ActivityLogAlertResource UpdateActivityLogAlertPsResource(PSActivityLogAlertResource inputObject)
209+
{
210+
var activityLogAlertResource = new ActivityLogAlertResource(
211+
inputObject.Location,
212+
inputObject.Scopes,
213+
new ActivityLogAlertAllOfCondition(inputObject.Condition.AllOf.Select(e => new ActivityLogAlertLeafCondition(field: e.Field, equals: e.Equals)).ToList()),
214+
new ActivityLogAlertActionList(inputObject.Actions.ActionGroups.Select(e => new ActivityLogAlertActionGroup(actionGroupId: e.ActionGroupId, webhookProperties: e.WebhookProperties)).ToList()),
215+
inputObject.Id,
216+
inputObject.Name,
217+
inputObject.Type,
218+
inputObject.Tags,
219+
inputObject.Enabled,
220+
inputObject.Description);
221+
222+
return UpdateActivityLogAlertResource(activityLogAlertResource);
223+
}
224+
208225
private ActivityLogAlertResource UpdateActivityLogAlertResource(ActivityLogAlertResource requestBody)
209226
{
210227
// There was an ActivityLogAlert already there, just modify what can be modifed

src/Monitor/Monitor/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Fixed input object parameter for `Set-AzActivityLogAlert`
2223
* Fixed bug for `Set-AzActionGroup`
2324

2425
## Version 2.0.0

0 commit comments

Comments
 (0)