Closed michelejohlbs closed 6 years ago
Double-check samples against a live Application Insights rule.
@michelejohlbs I'm unable to recreate your issue but am probably not testing the class of alert you are. Could you please describe your scenario in more detail? For example, are you seeing problems with metric alerts (what I tested), alerts on activity log events, or a subset of one or the other?
FYI the documentation at https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/insights-webhooks-alerts shows pretty much every field is mandatory.
@dougbu I got the issue when receiving an alert from an Application Insight Web Test Failure via the web hook.
Ah, yes. I do see this issue with Web Test alerts. The ASP.NET Core WebHooks workaround is to bind to JObject
instead of AzureAlertNotification
. For WebHooks 1.1, call context.GetDataOrDefault<JObject>()
instead of context.GetDataOrDefault<AzureAlertNotification>()
. Testing a quick fix locally…
Filed #203 about a related issue. We'll track supporting Availability alerts i.e. the AzureAlertContext
restrictiveness here.
Glad you found it @dougbu
4681759e4c
I created the receiver and used the AzureAlertNotification in order to serialize the context as per the example code. var notification =
context.GetDataOrDefault<AzureAlertNotification>();
The issue is that the notification POCO is null.
I created my own serialization class, but removed most of the “Required = Required.Always” on the JsonProperty attributes, except for Id, Name and Description. Using my own class it now works.
This means that the application insights notifications are not compliant with the Microsoft.AspNet.WebHooks.Receivers.Azure library, or that the library is not compliant with the application insights alerts.