/// <summary>
        /// Deletes the BLOB.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="blobIdentifier">The BLOB identifier.</param>
        public static void DeleteBlob(CloudBlobContainer container, string blobIdentifier)
        {
            try
            {
                container.CheckNullObject("container");

                var blob = container.GetBlockBlobReference(blobIdentifier);
                blob.Delete();
            }
            catch (Exception ex)
            {
                throw ex.Handle("DeleteBlob", new { container = container == null ? null : container.Uri.ToString(), blobIdentifier = blobIdentifier });
            }
        }
 /// <summary>
 /// Queries the BLOB.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="contentType">Type of the content.</param>
 /// <param name="md5">The MD5.</param>
 /// <param name="length">The length.</param>
 /// <param name="limitCount">The limit count.</param>
 /// <returns>IEnumerable&lt;CloudBlockBlob&gt;.</returns>
 public static IEnumerable<CloudBlockBlob> QueryBlob(CloudBlobContainer container, string contentType, string md5, long? length, int limitCount = 100)
 {
     try
     {
         container.CheckNullObject("container");
         if (string.IsNullOrWhiteSpace(contentType) && string.IsNullOrWhiteSpace(md5) && length == null)
         {
             return container.ListBlobs().OfType<CloudBlockBlob>().Take(limitCount);
         }
         else
         {
             return container.ListBlobs(blobListingDetails: BlobListingDetails.Metadata)
                 .OfType<CloudBlockBlob>()
                 .Where(item =>
                 {
                     return ((string.IsNullOrWhiteSpace(contentType) ||
                              item.Properties.ContentType.Equals(contentType,
                                  StringComparison.InvariantCultureIgnoreCase))
                             &&
                             (string.IsNullOrWhiteSpace(md5) ||
                              item.Properties.ContentMD5.Equals(md5,
                                  StringComparison.InvariantCultureIgnoreCase))
                             && (length == null || item.Properties.Length == length.Value));
                 }).Take(limitCount);
         }
     }
     catch (Exception ex)
     {
         throw ex.Handle("QueryBlob", new { container = container == null ? null : container.Uri.ToString(), contentType, md5, length, limitCount });
     }
 }
        /// <summary>
        /// Applies the BLOB policy.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="policyName">Name of the policy.</param>
        /// <param name="expireOffsetInMinute">The expire offset in minute.</param>
        /// <param name="permissions">The permissions.</param>
        protected static void ApplyBlobPolicy(CloudBlobContainer container, string policyName, int expireOffsetInMinute = 10, SharedAccessBlobPermissions permissions = SharedAccessBlobPermissions.List)
        {
            container.CheckNullObject("container");
            policyName.CheckEmptyString("policyName");

            //Get the container's existing permissions.
            var containerPermissions = new BlobContainerPermissions();

            var sharedPolicy = new SharedAccessBlobPolicy()
            {
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(expireOffsetInMinute),
                Permissions = permissions
            };

            //Add the new policy to the container's permissions.
            containerPermissions.SharedAccessPolicies.Clear();
            containerPermissions.SharedAccessPolicies.Add(policyName, sharedPolicy);
            container.SetPermissions(containerPermissions);
        }
        /// <summary>
        /// Queries the BLOB.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="filterFunction">The filter function.</param>
        /// <param name="limitCount">The limit count.</param>
        /// <returns>IEnumerable&lt;CloudBlockBlob&gt;.</returns>
        public static IEnumerable<CloudBlockBlob> QueryBlob(CloudBlobContainer container, Func<CloudBlockBlob, bool> filterFunction, int? limitCount = null)
        {
            try
            {
                container.CheckNullObject("container");

                if (filterFunction != null)
                {
                    return limitCount == null ? container.ListBlobs().OfType<CloudBlockBlob>().Where(filterFunction) : container.ListBlobs().OfType<CloudBlockBlob>().Where(filterFunction).Take(limitCount.Value);
                }
                else
                {
                    return limitCount == null ? container.ListBlobs().OfType<CloudBlockBlob>() : container.ListBlobs().OfType<CloudBlockBlob>().Take(limitCount.Value);
                }
            }
            catch (Exception ex)
            {
                throw ex.Handle("QueryBlob", new { container = container == null ? null : container.Uri.ToString(), limitCount = limitCount });
            }
        }