Skip to content

Commit 049e183

Browse files
committed
intial changes to include all the recievers, use common alert schema plus aad web hook changes
1 parent 0b9f9ec commit 049e183

17 files changed

+851
-17
lines changed

src/Monitor/Monitor.Test/ActionGroups/NewAzureRmActionGroupReceiverCommandTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public void NewAzureRmReceiverCommandSmsParametersProcessing()
6868
Cmdlet.SetParameterSet("NewSmsReceiver");
6969
Cmdlet.SmsReceiver = true;
7070
Cmdlet.Name = "sms1";
71-
Cmdlet.CountryCode = "1";
72-
Cmdlet.PhoneNumber = "4254251234";
71+
Cmdlet.SmsCountryCode = "1";
72+
Cmdlet.SmsPhoneNumber = "4254251234";
7373
Cmdlet.ExecuteCmdlet();
7474

7575
Func<PSSmsReceiver, bool> verify = r =>

src/Monitor/Monitor.Test/Monitor.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.22.0-preview" />
14+
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.24.1-preview" />
1515
<PackageReference Include="Microsoft.Azure.Management.ApplicationInsights" Version="0.2.0-preview" />
1616
</ItemGroup>
1717

src/Monitor/Monitor.Test/ScheduledQueryRules/NewScheduledQueryRuleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void NewScheduledQueryRuleCommandParametersProcessing()
9797
ScheduledQueryRuleAznsAction aznsAction = new ScheduledQueryRuleAznsAction(new AzNsActionGroup(new string[]{"AG1", "AG2"}, "Email Subject for Log Search Alert", "custom webhook payload"));
9898
ScheduledQueryRuleLogMetricTrigger logMetricTrigger = new ScheduledQueryRuleLogMetricTrigger(new LogMetricTrigger("GreaterThan", 15, "Total"));
9999
ScheduledQueryRuleTriggerCondition triggerCondition = new ScheduledQueryRuleTriggerCondition(new TriggerCondition("GreaterThan", 15, logMetricTrigger));
100-
ScheduledQueryRuleAlertingAction alertingAction = new ScheduledQueryRuleAlertingAction(new AlertingAction("2", aznsAction, triggerCondition, 5));
100+
ScheduledQueryRuleAlertingAction alertingAction = new ScheduledQueryRuleAlertingAction(new AlertingAction("2", triggerCondition, aznsAction, 5));
101101

102102
cmdlet.Action = new PSScheduledQueryRuleAlertingAction(alertingAction);
103103

src/Monitor/Monitor.Test/ScheduledQueryRules/SetScheduledQueryRuleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public SetScheduledQueryRuleTests(Xunit.Abstractions.ITestOutputHelper output)
5151

5252
ScheduledQueryRuleAznsAction aznsAction = new ScheduledQueryRuleAznsAction(new AzNsActionGroup());
5353
ScheduledQueryRuleTriggerCondition triggerCondition = new ScheduledQueryRuleTriggerCondition(new TriggerCondition("GreaterThan", 15));
54-
ScheduledQueryRuleAlertingAction alertingAction = new ScheduledQueryRuleAlertingAction(new AlertingAction("2", aznsAction, triggerCondition));
54+
ScheduledQueryRuleAlertingAction alertingAction = new ScheduledQueryRuleAlertingAction(new AlertingAction("2", aznsAction:aznsAction, trigger:triggerCondition));
5555

5656
ScheduledQueryRuleSchedule schedule = new ScheduledQueryRuleSchedule(new Schedule(5, 5));
5757

src/Monitor/Monitor/ActionGroups/NewAzureRmActionGroupReceiverCommand.cs

Lines changed: 308 additions & 8 deletions
Large diffs are not rendered by default.

src/Monitor/Monitor/ActionGroups/SetAzureRmActionGroupCommand.cs

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ protected override void ProcessRecordInternal()
130130
this.Receiver.AddRange(this.InputObject.EmailReceivers);
131131
this.Receiver.AddRange(this.InputObject.SmsReceivers);
132132
this.Receiver.AddRange(this.InputObject.WebhookReceivers);
133+
this.Receiver.AddRange(this.InputObject.ItsmReceivers);
134+
this.Receiver.AddRange(this.InputObject.VoiceReceivers);
135+
this.Receiver.AddRange(this.InputObject.ArmRoleReceivers);
136+
this.Receiver.AddRange(this.InputObject.AzureFunctionReceivers);
137+
this.Receiver.AddRange(this.InputObject.LogicAppReceivers);
138+
this.Receiver.AddRange(this.InputObject.AutomationRunbookReceivers);
139+
this.Receiver.AddRange(this.InputObject.AzureAppPushReceivers);
133140
}
134141
else if (ParameterSetName == ByResourceId)
135142
{
@@ -140,13 +147,72 @@ protected override void ProcessRecordInternal()
140147

141148
IList<EmailReceiver> emailReceivers =
142149
this.Receiver.OfType<PSEmailReceiver>().
143-
Select(o => new EmailReceiver(name: o.Name, emailAddress: o.EmailAddress, status: TransitionHelpers.ConvertNamespace(o.Status))).ToList();
150+
Select(o => new EmailReceiver(name: o.Name, emailAddress: o.EmailAddress, status: TransitionHelpers.ConvertNamespace(o.Status),useCommonAlertSchema : o.UseCommonAlertSchema)).ToList();
151+
144152
IList<SmsReceiver> smsReceivers =
145153
this.Receiver.OfType<PSSmsReceiver>().
146154
Select(o => new SmsReceiver(name: o.Name, countryCode: o.CountryCode, phoneNumber: o.PhoneNumber, status: TransitionHelpers.ConvertNamespace(o.Status))).ToList();
155+
147156
IList<WebhookReceiver> webhookReceivers =
148157
this.Receiver.OfType<PSWebhookReceiver>().
149-
Select(o => new WebhookReceiver(name: o.Name, serviceUri: o.ServiceUri)).ToList();
158+
Select(o => new WebhookReceiver(
159+
name: o.Name,
160+
serviceUri: o.ServiceUri,
161+
useCommonAlertSchema : o.UseCommonAlertSchema,
162+
useAadAuth :o.UseAadAuth,
163+
objectId : o.ObjectId,
164+
identifierUri: o.IdentifierUri,
165+
tenantId :o.TenantId)).ToList();
166+
167+
IList<ItsmReceiver> itsmReceivers =
168+
this.Receiver.OfType<PSItsmReceiver>().
169+
Select(o => new ItsmReceiver(name: o.Name, workspaceId: o.WorkspaceId, connectionId: o.ConnectionId, ticketConfiguration: o.TicketConfiguration, region: o.Region)).ToList();
170+
171+
IList <VoiceReceiver> voiceReceivers =
172+
this.Receiver.OfType<PSVoiceReceiver>().
173+
Select(o => new VoiceReceiver(name: o.Name, countryCode: o.CountryCode, phoneNumber: o.PhoneNumber)).ToList();
174+
175+
IList<ArmRoleReceiver> armRoleReceivers =
176+
this.Receiver.OfType<PSArmRoleReceiver>().
177+
Select(o => new ArmRoleReceiver(name: o.Name, roleId: o.RoleId, useCommonAlertSchema: o.UseCommonAlertSchema)).ToList();
178+
179+
IList<AzureFunctionReceiver> azureFunctionReceivers =
180+
this.Receiver.OfType<PSAzureFunctionReceiver>().
181+
Select(o => new AzureFunctionReceiver(
182+
name: o.Name,
183+
functionName: o.FunctionName,
184+
functionAppResourceId: o.FunctionAppResourceId,
185+
httpTriggerUrl: o.HttpTriggerUrl,
186+
useCommonAlertSchema: o.UseCommonAlertSchema)).ToList();
187+
188+
IList<LogicAppReceiver> logicAppReceivers =
189+
this.Receiver.OfType<PSLogicAppReceiver>().
190+
Select(o => new LogicAppReceiver(
191+
name: o.Name,
192+
resourceId: o.ResourceId,
193+
callbackUrl: o.CallbackUrl,
194+
useCommonAlertSchema: o.UseCommonAlertSchema
195+
)).ToList();
196+
197+
IList<AutomationRunbookReceiver> automationRunbookReceivers =
198+
this.Receiver.OfType<PSAutomationRunbookReceiver>().
199+
Select(o => new AutomationRunbookReceiver(
200+
name: o.Name,
201+
runbookName: o.RunbookName,
202+
webhookResourceId: o.WebhookResourceId,
203+
isGlobalRunbook: o.IsGlobalRunbook,
204+
useCommonAlertSchema: o.UseCommonAlertSchema,
205+
serviceUri: o.ServiceUri,
206+
automationAccountId :o.AutomationAccountId
207+
)).ToList();
208+
209+
IList<AzureAppPushReceiver> azureAppPushReceivers =
210+
this.Receiver.OfType<PSAzureAppPushReceiver>().
211+
Select(o => new AzureAppPushReceiver(
212+
name: o.Name,
213+
emailAddress: o.EmailAddress
214+
)).ToList();
215+
150216
ActionGroupResource actionGroup = new ActionGroupResource
151217
{
152218
Location = "Global",
@@ -155,7 +221,14 @@ protected override void ProcessRecordInternal()
155221
Tags = this.Tag,
156222
EmailReceivers = emailReceivers,
157223
SmsReceivers = smsReceivers,
158-
WebhookReceivers = webhookReceivers
224+
WebhookReceivers = webhookReceivers,
225+
ItsmReceivers = itsmReceivers,
226+
VoiceReceivers = voiceReceivers,
227+
ArmRoleReceivers = armRoleReceivers,
228+
AzureFunctionReceivers = azureFunctionReceivers,
229+
LogicAppReceivers = logicAppReceivers,
230+
AutomationRunbookReceivers = automationRunbookReceivers,
231+
AzureAppPushReceivers = azureAppPushReceivers
159232
};
160233

161234
WriteObject(

src/Monitor/Monitor/Monitor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.22.0-preview" />
14+
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.24.1-preview" />
1515
</ItemGroup>
1616

1717
</Project>

src/Monitor/Monitor/OutputClasses/PSActionGroupResource.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,55 @@ public class PSActionGroupResource : Resource
6565
/// </summary>
6666
public IList<PSWebhookReceiver> WebhookReceivers { get; set; }
6767

68+
/// <summary>
69+
/// Gets or sets the list of Itsm receivers that are part of this
70+
/// action group.
71+
///
72+
/// </summary>
73+
public IList<PSItsmReceiver> ItsmReceivers { get; set; }
74+
75+
/// <summary>
76+
/// Gets or sets the list of voice receivers that are part of this
77+
/// action group.
78+
///
79+
/// </summary>
80+
public IList<PSVoiceReceiver> VoiceReceivers { get; set; }
81+
82+
/// <summary>
83+
/// Gets or sets the list of arm role receivers that are part of this
84+
/// action group.
85+
///
86+
/// </summary>
87+
public IList<PSArmRoleReceiver> ArmRoleReceivers { get; set; }
88+
89+
/// <summary>
90+
/// Gets or sets the list of AzureFunctionReceivers that are part of this
91+
/// action group.
92+
///
93+
/// </summary>
94+
public IList<PSAzureFunctionReceiver> AzureFunctionReceivers { get; set; }
95+
96+
/// <summary>
97+
/// Gets or sets the list of LogicAppReceivers that are part of this
98+
/// action group.
99+
///
100+
/// </summary>
101+
public IList<PSLogicAppReceiver> LogicAppReceivers { get; set; }
102+
103+
/// <summary>
104+
/// Gets or sets the list of AutomationRunbookReceivers that are part of this
105+
/// action group.
106+
///
107+
/// </summary>
108+
public IList<PSAutomationRunbookReceiver> AutomationRunbookReceivers { get; set; }
109+
110+
/// <summary>
111+
/// Gets or sets the list of AzureAppPushReceivers that are part of this
112+
/// action group.
113+
///
114+
/// </summary>
115+
public IList<PSAzureAppPushReceiver> AzureAppPushReceivers { get; set; }
116+
68117
/// <summary>Initializes a new instance of the PSActionGroup class.</summary>
69118
/// <param name="actionGroupResource">the action group resource</param>
70119
public PSActionGroupResource(ActionGroupResource actionGroupResource)
@@ -81,6 +130,13 @@ public PSActionGroupResource(ActionGroupResource actionGroupResource)
81130
EmailReceivers = actionGroupResource.EmailReceivers?.Select(o => new PSEmailReceiver(o)).ToList();
82131
SmsReceivers = actionGroupResource.SmsReceivers?.Select(o => new PSSmsReceiver(o)).ToList();
83132
WebhookReceivers = actionGroupResource.WebhookReceivers?.Select(o => new PSWebhookReceiver(o)).ToList();
133+
ArmRoleReceivers = actionGroupResource.ArmRoleReceivers?.Select(o => new PSArmRoleReceiver(o)).ToList();
134+
ItsmReceivers = actionGroupResource.ItsmReceivers?.Select(o => new PSItsmReceiver(o)).ToList();
135+
VoiceReceivers = actionGroupResource.VoiceReceivers?.Select(o => new PSVoiceReceiver(o)).ToList();
136+
AzureFunctionReceivers = actionGroupResource.AzureFunctionReceivers?.Select(o => new PSAzureFunctionReceiver(o)).ToList();
137+
LogicAppReceivers = actionGroupResource.LogicAppReceivers?.Select(o => new PSLogicAppReceiver(o)).ToList();
138+
AutomationRunbookReceivers = actionGroupResource.AutomationRunbookReceivers?.Select(o => new PSAutomationRunbookReceiver(o)).ToList();
139+
AzureAppPushReceivers = actionGroupResource.AzureAppPushReceivers?.Select(o => new PSAzureAppPushReceiver(o)).ToList();
84140
}
85141
}
86142
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Management.Monitor.Models;
16+
17+
namespace Microsoft.Azure.Commands.Insights.OutputClasses
18+
{
19+
/// <summary>
20+
/// Wraps the ArmRoleReceiver class.
21+
/// </summary>
22+
public class PSArmRoleReceiver : PSActionGroupReceiverBase
23+
{
24+
/// <summary>Gets or sets the role id of this receiver.</summary>
25+
public string RoleId { get; set; }
26+
27+
/// <summary>Gets or sets a value indicating whether or not use common alert schema.</summary>
28+
public bool UseCommonAlertSchema { get; set; }
29+
30+
/// <summary>Initializes a new instance of the PSArmRoleReceiver class</summary>
31+
public PSArmRoleReceiver()
32+
{
33+
}
34+
35+
/// <summary>
36+
/// Initializes a new instance of the PSArmRoleReceiver class.
37+
/// </summary>
38+
/// <param name="receiver">The receiver to wrap.</param>
39+
public PSArmRoleReceiver(ArmRoleReceiver receiver)
40+
{
41+
this.Name = receiver.Name;
42+
this.RoleId = receiver.RoleId;
43+
this.UseCommonAlertSchema = receiver.UseCommonAlertSchema;
44+
}
45+
}
46+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Management.Monitor.Models;
16+
17+
namespace Microsoft.Azure.Commands.Insights.OutputClasses
18+
{
19+
/// <summary>
20+
/// Wraps the AutomationRunbookReceiver class.
21+
/// </summary>
22+
public class PSAutomationRunbookReceiver : PSActionGroupReceiverBase
23+
{
24+
/// <summary>Gets or sets automation account identifier</summary>
25+
public string AutomationAccountId { get; set; }
26+
27+
/// <summary>Gets or sets the name of the runbook.</summary>
28+
public string RunbookName { get; set; }
29+
30+
/// <summary>Gets or sets the name of the webhook resource id.</summary>
31+
public string WebhookResourceId { get; set; }
32+
33+
/// <summary>Gets or sets a value indicating whether this instance is global runbook</summary>
34+
public bool IsGlobalRunbook { get; set; }
35+
36+
/// <summary>Gets or sets a value indicating whether or not use common alert schema.</summary>
37+
public bool UseCommonAlertSchema { get; set; }
38+
39+
/// <summary> Gets or sets the URI where webhooks should be sent..</summary>
40+
public string ServiceUri { get; set; }
41+
42+
/// <summary>Initializes a new instance of the PSAutomationRunbookReceiver class</summary>
43+
public PSAutomationRunbookReceiver()
44+
{
45+
}
46+
47+
/// <summary>
48+
/// Initializes a new instance of the PSAutomationRunbookReceiver class.
49+
/// </summary>
50+
/// <param name="receiver">The receiver to wrap.</param>
51+
public PSAutomationRunbookReceiver(AutomationRunbookReceiver receiver)
52+
{
53+
this.Name = receiver.Name;
54+
this.AutomationAccountId = receiver.AutomationAccountId;
55+
this.RunbookName = receiver.RunbookName;
56+
this.WebhookResourceId = receiver.WebhookResourceId;
57+
this.IsGlobalRunbook = receiver.IsGlobalRunbook;
58+
this.UseCommonAlertSchema = receiver.UseCommonAlertSchema;
59+
this.ServiceUri = receiver.ServiceUri;
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)