private static async Task WriteBlob(string auditData, string fullPath, ISimpleCloudBlob blob) { try { using (var stream = await blob.OpenWriteAsync(AccessCondition.GenerateIfNoneMatchCondition("*"))) using (var writer = new StreamWriter(stream)) { await writer.WriteAsync(auditData); } } catch (StorageException ex) { if (ex.RequestInformation != null && ex.RequestInformation.HttpStatusCode == 409) { // Blob already existed! throw new InvalidOperationException(String.Format( CultureInfo.CurrentCulture, CoreStrings.CloudAuditingService_DuplicateAuditRecord, fullPath), ex); } throw; } }
public static async Task <Stream> OpenWriteAsync(this ISimpleCloudBlob blob, IAccessCondition accessCondition) { return(await blob.OpenWriteAsync(MapAccessCondition(accessCondition))); }