コード例 #1
0
        public static async Task ProcessSentinelIncidentsAsync()
        {
            var sentinelIncidentService = new AzureSentinelIncidentService();
            var incidents = await sentinelIncidentService.GetIncidentsAsync(IncidentStatus.New, 20, _Workspace);

            foreach (var incident in incidents)
            {
                var stringEnumConverter = new System.Text.Json.Serialization.JsonStringEnumConverter();
                var options             = new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                };
                options.Converters.Add(stringEnumConverter);

                var json = JsonSerializer.Serialize <SentinelIncident>(incident, options);

                await _EventHubService.PublishMessageAsync(json);

                // update the incident status.
                incident.Properties.Status = IncidentStatus.Active;

                await sentinelIncidentService.UpdateIncidentAsync(incident, incident.Name, _Workspace);

                System.Console.WriteLine(String.Format("Incidentnr {0} is forwared to eventhub", incident.Properties.IncidentNumber));
            }
        }
コード例 #2
0
        public JsonSerializerOptions GetJsonSerializerOptions()
        {
            var stringEnumConverter = new System.Text.Json.Serialization.JsonStringEnumConverter();
            var options             = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
            };

            options.Converters.Add(stringEnumConverter);

            return(options);
        }