/// <summary> /// Defines the entry point of the application. /// </summary> public static void Main() { Console.Write("Press ENTER to start..."); Console.ReadLine(); ConfigureAuditing.ForCurrentSignedInUser(); var client = new AuditHttpClient(ConfigurationManager.AppSettings["Audit.ServiceBase"]); ///var client = new AuditServiceBusClient(ConfigurationManager.AppSettings["Audit.ServiceBus"]); var program = new Program(client); program.Run().Wait(); Console.Write("Press ENTER to quit..."); Console.ReadLine(); }
public async Task DownloadSampleAsync() { // Get the audit log client VssConnection connection = Context.Connection; AuditHttpClient auditClient = await connection.GetClientAsync <AuditHttpClient>(); // Download the log to a file foreach (string format in new[] { "json", "csv" }) { string fileName = $"{Path.GetTempFileName()}.{format}"; using (FileStream fileStream = File.Create(fileName)) using (Stream logStream = await auditClient.DownloadLogAsync(format)) { await logStream.CopyToAsync(fileStream); } Context.Log($"Log downloaded to {fileName}"); } }
public async Task QueryLogSampleAsync() { try { // Get the audit log client VssConnection connection = Context.Connection; AuditHttpClient auditClient = await connection.GetClientAsync <AuditHttpClient>(); // Query the audit log for the last day, take only 10 entries DateTime now = DateTime.UtcNow; AuditLogQueryResult logQueryResult = await auditClient .QueryLogAsync(startTime : now.AddDays(-1), endTime : now, batchSize : 10, continuationToken : null); Context.Log($"ContinuationToken: {logQueryResult.ContinuationToken}"); Context.Log($"HasMore: {logQueryResult.HasMore}"); Context.Log($"DecoratedAuditLogEntries: {logQueryResult.DecoratedAuditLogEntries.Count()}"); } catch (Exception e) { Context.Log($"err: {e}"); } }