public static string RenderAuditRecord(AuditRecord auditRecord) { return JsonConvert.SerializeObject(auditRecord, _auditRecordSerializerSettings); }
internal static void SaveAuditRecord(CloudStorageAccount storage, string name, AuditRecord auditRecord) { // Write the record to a temp file string tempFile = null; try { tempFile = Path.GetTempFileName(); string report = RenderAuditRecord(auditRecord); File.WriteAllText(tempFile, report); // Get the blob var client = storage.CreateCloudBlobClient(); var container = client.GetContainerReference("auditing"); container.CreateIfNotExists(); var blob = container.GetBlockBlobReference(name); if (blob.Exists()) { throw new InvalidOperationException("Duplicate audit record found! " + name); } blob.UploadFile(tempFile); } finally { if (!String.IsNullOrEmpty(tempFile) && File.Exists(tempFile)) { File.Delete(tempFile); } } }