/// <summary> /// Creates Cloud Append Blob /// </summary> /// <param name="blobName">The blobId for the Append block blob</param> /// <param name="contentType">The content type for the Append block blob</param> /// <returns>The created Append block blob</returns> public async Task <CloudAppendBlob> CreateAppendBlobAsync(string blobName, string contentType = "text/plain") { ThrowWhenCloudBlobContainerDoesNotExist(); _validateStorage.ValidateBlobName(blobName, BLOBNAME); var appendBlob = Container.GetAppendBlobReference(blobName); appendBlob.Metadata[BLOBNAME] = blobName; appendBlob.Properties.ContentType = contentType; if (!await appendBlob.ExistsAsync()) { await appendBlob.CreateOrReplaceAsync(); } return(appendBlob); }
/// <summary> /// Put (create or update) a block blob /// </summary> /// <param name="blobName">blob name</param> /// <param name="value">Class of T value</param> public async Task <CloudBlockBlob> SetAsync(string blobName, T value) { Contract.Requires <ArgumentNullException>(!string.IsNullOrWhiteSpace(blobName), "blobName cannot be null or empty"); _validateStorage.ValidateBlobName(blobName, BLOBNAME); var bytes = value.SerializeWithCompression(); CloudBlockBlob result; using (var memoryStream = new MemoryStream(bytes)) { result = await SetBlobFromStreamAsync(blobName, memoryStream, "gzip"); } return(result); }