// Create a snapshot of a blob. // Return true on success, false if unable to create, throw exception on error. public bool SnapshotBlob(string containerName, string blobName) { try { CloudBlobContainer container = BlobClient.GetContainerReference(containerName); CloudBlob blob = container.GetBlobReference(blobName); blob.CreateSnapshot(); return(true); } catch (StorageClientException ex) { if ((int)ex.StatusCode == 404) { return(false); } throw; } }
/// <summary> /// Get Cloud Data /// </summary> /// <returns>Data for object</returns> public byte[] GetData() { var bytes = this.blob.DownloadByteArray(); if (string.IsNullOrWhiteSpace(this.MD5)) { using (var createHash = System.Security.Cryptography.MD5.Create()) { var hash = createHash.ComputeHash(bytes); this.MD5 = System.Convert.ToBase64String(hash); } if (createSnapShot) { blob.CreateSnapshot(); } blob.Properties.ContentMD5 = this.MD5; this.blob.Metadata[MD5MetadataKey] = this.MD5; this.blob.SetMetadata(); } return(bytes); }