示例#1
0
        /// <summary>
        /// Private method for Image Deletion in Storage
        /// </summary>
        /// <param name="path">Path of Image</param>
        /// <param name="thumbnailpath">Thumb path of Image</param>
        /// <returns></returns>
        private bool DeleteImageFromStorage(string path, string thumbnailpath)
        {
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();
            CloudBlob       blobpath   = blobClient.GetBlobReference(path);
            CloudBlob       blobthpath = blobClient.GetBlobReference(thumbnailpath);

            return(blobpath.DeleteIfExists() && blobthpath.DeleteIfExists());
        }
        /// <summary>
        /// Creates a new public blob
        /// </summary>
        /// <param name="containerName">Name of Container</param>
        /// <param name="fileName">Name of the file</param>
        /// <param name="fileStream">File as <see cref="Stream"/> to upload</param>
        /// <returns>The Uri of the file</returns>
        public string CreatePublicBlob(string containerName, string fileName, Stream fileStream)
        {
            string blobReference = string.Concat(containerName, "/", fileName);
            //Create a new blob and write some text to it.
            CloudBlob blob = _blobClient.GetBlobReference(blobReference);

            blob.UploadFromStream(fileStream);

            //Set the Cache-Control header on the blob.
            blob.SetCacheControl("public");

            return(blob.Uri.ToString());
        }
示例#3
0
        /// <summary>
        /// Creates the silverlight policy file in storage account.
        /// </summary>
        /// <param name="blobs">The blob client.</param>
        private static void CreateSilverlightPolicy(CloudBlobClient blobs)
        {
            blobs.GetContainerReference("$root").CreateIfNotExist();
            blobs.GetContainerReference("$root").SetPermissions(
                new BlobContainerPermissions()
            {
                PublicAccess = BlobContainerPublicAccessType.Blob
            });
            var blob = blobs.GetBlobReference("clientaccesspolicy.xml");

            blob.Properties.ContentType = "text/xml";
            blob.UploadText(@"<?xml version=""1.0"" encoding=""utf-8""?>
                    <access-policy>
                      <cross-domain-access>
                        <policy>
                          <allow-from http-methods=""*"" http-request-headers=""*"">
                            <domain uri=""*"" />
                            <domain uri=""http://*"" />
                          </allow-from>
                          <grant-to>
                            <resource path=""/"" include-subpaths=""true"" />
                          </grant-to>
                        </policy>
                      </cross-domain-access>
                    </access-policy>");
        }
示例#4
0
        private void DeleteBlobs(IList <string> blobs, CancellationToken cancelToken, Action <string> fileDeletedAction, Action <string, Exception> fileFailedAction)
        {
            Parallel.ForEach(
                blobs,
                new ParallelOptions {
                MaxDegreeOfParallelism = ArgSettings.Parallelism, CancellationToken = cancelToken
            },
                (blob, loopState) =>
            {
                try
                {
                    blobClient.GetBlobReference(blob).Delete();

                    if (!loopState.IsStopped && fileDeletedAction != null)
                    {
                        fileDeletedAction(blob);
                    }
                }
                catch (Exception ex)
                {
                    if (!loopState.IsStopped && fileFailedAction != null)
                    {
                        fileFailedAction(blob, ex);
                    }
                }
            });
        }
        private void ProcessAnonymousRequest(HttpRequest request, HttpResponse response)
        {
            CloudBlobClient publicClient = new CloudBlobClient("http://theball.blob.core.windows.net/");
            string          blobPath     = GetBlobPath(request);
            CloudBlob       blob         = publicClient.GetBlobReference(blobPath);

            response.Clear();
            try
            {
                blob.FetchAttributes();
                response.ContentType = blob.Properties.ContentType;
                blob.DownloadToStream(response.OutputStream);
            } catch (StorageClientException scEx)
            {
                if (scEx.ErrorCode == StorageErrorCode.BlobNotFound || scEx.ErrorCode == StorageErrorCode.ResourceNotFound || scEx.ErrorCode == StorageErrorCode.BadRequest)
                {
                    response.Write("Blob not found or bad request: " + blob.Name + " (original path: " + request.Path + ")");
                    response.StatusCode = (int)scEx.StatusCode;
                }
                else
                {
                    response.Write("Errorcode: " + scEx.ErrorCode.ToString() + Environment.NewLine);
                    response.Write(scEx.ToString());
                    response.StatusCode = (int)scEx.StatusCode;
                }
            } finally
            {
                response.End();
            }
        }
示例#6
0
        private void ChangeContentTypeForFiles(IAsset asset, string contentType, string fileExtension)
        {
            var connectionString =
                ConfigurationManager.AppSettings["MediaServicesStorageAccountConnectionString"];

            var account = CloudStorageAccount.Parse(connectionString);

            CloudBlobClient client = null;

            foreach (var assetFile in asset.Files)
            {
                bool shouldChangeContentType = !assetFile.Name.Contains(fileExtension) ||
                                               (assetFile.MimeType != null &&
                                                assetFile.MimeType.Equals(
                                                    contentType, StringComparison.InvariantCultureIgnoreCase));

                if (shouldChangeContentType)
                {
                    continue;
                }

                client = client ?? account.CreateCloudBlobClient();

                var writeSasLocator = this.mediaCloudHelper.CreateSasLocator(
                    asset, AccessPermissions.Write, TimeSpan.FromMinutes(2));
                var assetContainerName = writeSasLocator.Path.Split('?')[0];

                var blobPath = string.Concat(assetContainerName, "/", assetFile.Name);
                var blob     = client.GetBlobReference(blobPath);
                blob.Properties.ContentType = contentType;
                blob.SetProperties();
            }
        }
示例#7
0
        static void Main(string[] args)
        {
            //Replace the credentials with your own.
            StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey("silverliningstorage1",
                                                                                              "ZXdXkdkUa7EMxoTtygmbC8CV9keeMxWrBOQaFCfYHNZYjj8DX56y0DofQaaC3DmgCGf049C/SSgEnhapWWoTjT1/zXPAi==");

            //Create a storage account instance
            CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, true);

            //Create a new blob client instance
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            //Create a new container instance
            CloudBlobContainer container = blobClient.GetContainerReference("mycdn");

            //Create the container if it does not exist
            container.CreateIfNotExist();

            //Specify that the container is publicly accessible. This is a requirement for CDN
            BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

            containerPermissions.PublicAccess = BlobContainerPublicAccessType.Container;
            container.SetPermissions(containerPermissions);

            //Create a new blob
            CloudBlob blob = blobClient.GetBlobReference("mycdn/mytestblob.txt");

            blob.UploadText("My first CDN Blob.");

            //Set the Cache-Control header property of the blob and specify your desired refresh interval (in seconds).
            blob.Properties.CacheControl = "public, max-age=30036000";
            blob.SetProperties();
        }
        /// <summary>
        /// Deletes the entity.
        /// </summary>
        /// <param name="entity">The <see cref="T"/> entity.</param>
        public void Delete(T entity)
        {
            string    location = @"DalEntityBase.Delete";
            Stopwatch watch    = Stopwatch.StartNew();

            if (entity == null)
            {
                throw new ArgumentException("entity");
            }

            try
            {
                CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
                CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}", this.container.Name, this.BlobDirectoryName, entity.Identifier));
                blob.DeleteIfExists();

                this.DeleteExtended(entity);
            }
            catch (Exception exception)
            {
                LoggerFactory.Logger.Error(location, EventId.DALDeleteEntity
                                           , "Error while deleting entity {0} in folder {1} in container {2}: {3}."
                                           , entity.Identifier, this.BlobDirectoryName, this.container.Name, exception.ToString());
                throw;
            }
            finally
            {
                watch.Stop();
                LoggerFactory.Logger.Debug(location, "Delete({0}) for type {1} finished in {2} ms.", entity.Identifier, typeof(T), watch.ElapsedMilliseconds);
            }
        }
示例#9
0
        public static IEnumerable <WellaMates.Models.File> ProcessFiles(IEnumerable <WellaMates.Models.File> files)
        {
            var storageAccount = CloudStorageAccount.Parse(
                ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);

            var blobClient = storageAccount.CreateCloudBlobClient();
            var container  = blobClient.GetContainerReference(AzureBlobSA.REFUND_FILES_CONTAINER);

            var containerPermissions = new BlobContainerPermissions();

            containerPermissions.SharedAccessPolicies.Add(
                AzureBlobSA.THIRTY_MINUTE_POLICY, new SharedAccessPolicy()
            {
                SharedAccessStartTime  = DateTime.UtcNow.AddMinutes(-5),
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30),
                Permissions            = SharedAccessPermissions.Read
            });
            containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
            container.SetPermissions(containerPermissions);
            var sas           = container.GetSharedAccessSignature(new SharedAccessPolicy(), AzureBlobSA.THIRTY_MINUTE_POLICY);
            var sasBlobClient = new CloudBlobClient(storageAccount.BlobEndpoint,
                                                    new StorageCredentialsSharedAccessSignature(sas));

            var processFiles = files as File[] ?? files.ToArray();

            foreach (var file in processFiles)
            {
                file.FilePath =
                    sasBlobClient.GetBlobReference(AzureBlobSA.REFUND_FILES_CONTAINER + @"/" + file.FilePath)
                    .Uri.AbsoluteUri + sas;
            }
            return(processFiles);
        }
示例#10
0
        private void writeStuff()
        {
            CloudBlobClient threadClient = storageAccount.CreateCloudBlobClient();

            threadClient.GetBlobReference("threadtest/" + Guid.NewGuid().ToString()).UploadText("Hello " + Guid.NewGuid().ToString());
            semaphore.Release();
        }
        public void DeleteBtsAssemblyFiles(BtsAssemblyFilesMetadata mapFilesMetadata)
        {
            CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
            CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}",
                                                                           this.container.Name, mapFilesMetadata.FileName));

            blob.DeleteIfExists();
        }
示例#12
0
        public void DeleteBizRuleCert(BizRuleCertMetadata bizRuleCertMetadata)
        {
            CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
            CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}",
                                                                           this.container.Name, bizRuleCertMetadata.RuleCertFileName));

            blob.DeleteIfExists();
        }
        public void DeleteTradingPartnerSpecCert(TradingPartnerSpecCertMetadata tradingPartnerSpecCertMetadata)
        {
            CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
            CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}",
                                                                           this.container.Name, tradingPartnerSpecCertMetadata.SchemaFileName));

            blob.DeleteIfExists();
        }
示例#14
0
        public void Clear()
        {
            var blobs = container.ListBlobs();

            foreach (var blob in blobs)
            {
                _blobClient.GetBlobReference(blob.Uri + "").DeleteIfExists();
            }
        }
示例#15
0
        public void PutBlob(string filename, string blobName)
        {
            CloudBlob blob = cloudBlobClient.GetBlobReference(blobName);

            blob.Properties.ContentType = MimeTypeHelper.GetMimeType(filename);

            blob.UploadFile(filename);
            Trace.TraceInformation("Done");
        }
示例#16
0
        public static string GetSasBlobUrl(string containerName, string fileName, string sas)
        {
            var storageAccount = CloudStorageAccount.Parse(
                ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);
            var sasBlobClient = new CloudBlobClient(storageAccount.BlobEndpoint,
                                                    new StorageCredentialsSharedAccessSignature(sas));
            var blob = sasBlobClient.GetBlobReference(containerName + @"/" + fileName);

            return(blob.Uri.AbsoluteUri + sas);
        }
		/// <summary>
		/// Deletes the theme with the given name.
		/// </summary>
		/// <param name="themeName">The name of the theme to be deleted.</param>
		/// <returns><c>true</c> if the theme is removed, <c>false</c> otherwise.</returns>
		public bool DeleteTheme(string themeName) {
			var containerRef = _client.GetContainerReference(_wiki + "-themes");
			var directoryRef = containerRef.GetDirectoryReference(themeName);
			BlobRequestOptions options = new BlobRequestOptions();
			options.UseFlatBlobListing = true;
			var blobs = directoryRef.ListBlobs(options);
			foreach(var blob in blobs) {
				_client.GetBlobReference(blob.Uri.AbsoluteUri).Delete();
			}
			return true;
		}
        public Stream GetBtsAssemblyFiles(BtsAssemblyFilesMetadata mapFilesMetadata)
        {
            CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
            CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.container.Name, mapFilesMetadata.FileName));

            MemoryStream ms = new MemoryStream();

            blob.DownloadToStream(ms);
            ms.Position = 0;

            return(ms);
        }
        public Stream GetTradingPartnerSpecCert(TradingPartnerSpecCertMetadata tradingPartnerSpecCertMetadata)
        {
            CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
            CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.container.Name, tradingPartnerSpecCertMetadata.SchemaFileName));

            MemoryStream ms = new MemoryStream();

            blob.DownloadToStream(ms);
            ms.Position = 0;

            return(ms);
        }
示例#20
0
        public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
        {
            StorageService storageKeys = channel.GetStorageKeys(subscriptionId, storageName);
            string         primary     = storageKeys.StorageServiceKeys.Primary;

            storageKeys = channel.GetStorageService(subscriptionId, storageName);
            EndpointList endpoints = storageKeys.StorageServiceProperties.Endpoints;
            string       str       = ((List <string>)endpoints).Find((string p) => p.Contains(".blob."));
            StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(storageName, primary);
            CloudBlobClient cloudBlobClient = new CloudBlobClient(str, storageCredentialsAccountAndKey);
            CloudBlob       blobReference   = cloudBlobClient.GetBlobReference(packageUri.AbsoluteUri);

            blobReference.DeleteIfExists();
        }
示例#21
0
        private void DownloadSimulationFiles()
        {
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            foreach (var item in blobClient.GetContainerReference("simulation").ListBlobs())
            {
                CloudBlob blob = blobClient.GetBlobReference(item.Uri.ToString());

                FileStream _file = new FileStream(Path.Combine(this.LocalStorageRoot, item.Uri.ToString().Substring(item.Uri.ToString().LastIndexOf('/') + 1)), FileMode.Create);
                Trace.WriteLine(_file.Name);
                blob.DownloadToStream(_file);
                Trace.WriteLine("Done");
                _file.Close();
            }
        }
示例#22
0
        private void DownloadSimulationFiles()
        {
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            foreach (var item in blobClient.GetContainerReference("gmt").ListBlobs())
            {
                CloudBlob blob = blobClient.GetBlobReference(item.Uri.ToString());

                FileStream _file = new FileStream(Path.Combine(this.LocalStorageRoot, item.Uri.ToString().Substring(item.Uri.ToString().LastIndexOf('/') + 1)), FileMode.Create);

                blob.DownloadToStream(_file, new BlobRequestOptions()
                {
                    Timeout = System.TimeSpan.FromMinutes(5)
                });
                _file.Close();
            }
        }
示例#23
0
        /// <summary>
        /// Deletes all blobs in all containers.
        /// Used only in tests tear-down method
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        public static void DeleteAllBlobs(string connectionString)
        {
            CloudBlobClient _client = TableStorage.StorageAccount(connectionString).CreateCloudBlobClient();

            _client.RetryPolicy = GetDefaultRetryPolicy();

            foreach (CloudBlobContainer containerRef in _client.ListContainers())
            {
                BlobRequestOptions options = new BlobRequestOptions();
                options.UseFlatBlobListing = true;
                IEnumerable <IListBlobItem> blobs = containerRef.ListBlobs(options);
                foreach (IListBlobItem blob in blobs)
                {
                    var blobRef = _client.GetBlobReference(blob.Uri.AbsoluteUri);
                    blobRef.DeleteIfExists();
                }
            }
        }
示例#24
0
        private CloudBlob GetBlobDetail(Uri uri)
        {
            lock (blobCache)
            {
                CloudBlob blob = blobCache[uri.OriginalString] as CloudBlob;
                if (null == blob)
                {
                    blob = client.GetBlobReference(uri.OriginalString);
                    blob.FetchAttributes();
                    blobCache.Add(uri.OriginalString, blob, new CacheItemPolicy()
                    {
                        AbsoluteExpiration = DateTime.Now.AddMinutes(1)
                    });
                }

                return(blob);
            }
        }
        /// <summary>
        /// Gets an entity.
        /// </summary>
        /// <param name="identifier">The entity identifier.</param>
        /// <returns>The <see cref="T"/> entity.</returns>
        public T Get(string identifier)
        {
            string    location = @"DalEntityBase.Get";
            Stopwatch watch    = Stopwatch.StartNew();

            if (string.IsNullOrEmpty(identifier))
            {
                throw new ArgumentException("identifier");
            }

            T result = null;

            try
            {
                CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
                CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}", this.container.Name, this.BlobDirectoryName, identifier));
                using (MemoryStream stream = new MemoryStream())
                {
                    blob.DownloadToStream(stream);
                    stream.Seek(0, SeekOrigin.Begin);

                    BinaryFormatter formatter = new BinaryFormatter();
                    result = formatter.Deserialize(stream) as T;
                }

                if (result != null)
                {
                    result = this.GetExtended(result);
                }
            }
            catch (Exception exception)
            {
                LoggerFactory.Logger.Warning(location, EventId.DALGetEntity
                                             , "Error while getting entity {0} in folder {1} in container {2}: {3}."
                                             , identifier, this.BlobDirectoryName, this.container.Name, exception.ToString());
            }
            finally
            {
                watch.Stop();
                LoggerFactory.Logger.Debug(location, "Get({0}) for type {1} finished in {2} ms.", identifier, typeof(T), watch.ElapsedMilliseconds);
            }

            return(result);
        }
示例#26
0
        public static void RemoveVHD(IServiceManagement channel, string subscriptionId, Uri mediaLink)
        {
            StorageService storageKeys;

            char[] chrArray = new char[1];
            chrArray[0] = '.';
            string str        = mediaLink.Host.Split(chrArray)[0];
            string components = mediaLink.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)channel))
            {
                storageKeys = channel.GetStorageKeys(subscriptionId, str);
            }
            StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(str, storageKeys.StorageServiceKeys.Primary);
            CloudBlobClient cloudBlobClient = new CloudBlobClient(components, storageCredentialsAccountAndKey);
            CloudBlob       blobReference   = cloudBlobClient.GetBlobReference(mediaLink.AbsoluteUri);

            blobReference.DeleteIfExists();
        }
示例#27
0
        private FineUploadSession[] GetRefundItemSession(int targetId)
        {
            var session = new List <FineUploadSession>();

            try
            {
                var storageAccount = CloudStorageAccount.Parse(
                    ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);

                var blobClient = storageAccount.CreateCloudBlobClient();
                var container  = blobClient.GetContainerReference(AzureBlobSA.REFUND_FILES_CONTAINER);

                var containerPermissions = new BlobContainerPermissions();
                containerPermissions.SharedAccessPolicies.Add(
                    AzureBlobSA.THIRTY_MINUTE_POLICY, new SharedAccessPolicy()
                {
                    SharedAccessStartTime  = DateTime.UtcNow.AddMinutes(-5),
                    SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30),
                    Permissions            = SharedAccessPermissions.Read
                });
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
                container.SetPermissions(containerPermissions);
                var sas           = container.GetSharedAccessSignature(new SharedAccessPolicy(), AzureBlobSA.THIRTY_MINUTE_POLICY);
                var sasBlobClient = new CloudBlobClient(storageAccount.BlobEndpoint,
                                                        new StorageCredentialsSharedAccessSignature(sas));

                using (var db = new PortalContext())
                {
                    var files = db.RefundItems.First(r => r.RefundItemID == targetId).Files;
                    session.AddRange(files.Select(file => new FineUploadSession
                    {
                        name         = file.Name,
                        thumbnailUrl = sasBlobClient.GetBlobReference(AzureBlobSA.REFUND_FILES_CONTAINER + @"/" + file.FilePath).Uri.AbsoluteUri + sas,
                        uuid         = file.FilePath
                    }));
                }
            }
            catch (Exception e)
            {
                session = null;
            }
            return(session == null ? null : session.ToArray());
        }
        public SignUploadResponse SignUpload(Guid guid)
        {
            var blobReference = _BlobClient.GetBlobReference(string.Format("{0}/{1}.jpg",
                                                                           "photos", guid.ToString()));
            var start = DateTime.UtcNow;
            var end   = DateTime.UtcNow.AddMinutes(59.5);
            var sig   = blobReference.GetSharedAccessSignature(new SharedAccessPolicy {
                Permissions            = SharedAccessPermissions.Write,
                SharedAccessStartTime  = DateTime.UtcNow,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(59.5)
            });

            var signedUrl = blobReference.Uri.ToString() + sig;

            return(new SignUploadResponse {
                ReportKey = guid,
                Url = new Uri(signedUrl)
            });
        }
示例#29
0
        public IEnumerable <CloudBlob> Translate(IExpression expression, CloudBlobClient blobClient, MediaFolder mediaFolder)
        {
            this.Visite(expression);

            if (!string.IsNullOrEmpty(fileName))
            {
                var blob = blobClient.GetBlobReference(mediaFolder.GetMediaFolderItemPath(fileName));
                blob.FetchAttributes();
                return(new[] { blob });
            }
            else
            {
                var maxResult = 100;
                if (Take.HasValue)
                {
                    maxResult = Take.Value;
                }
                var take = maxResult;

                var skip = 0;
                if (Skip.HasValue)
                {
                    skip      = Skip.Value;
                    maxResult = +skip;
                }
                var blobPrefix = mediaFolder.GetMediaFolderItemPath(prefix);

                if (string.IsNullOrEmpty(prefix))
                {
                    blobPrefix += "/";
                }

                return(blobClient.ListBlobsWithPrefixSegmented(blobPrefix, maxResult, null, new BlobRequestOptions()
                {
                    BlobListingDetails = Microsoft.WindowsAzure.StorageClient.BlobListingDetails.Metadata, UseFlatBlobListing = false
                })
                       .Results.Skip(skip).Select(it => it as CloudBlob).Take(take));
            }
        }
        /// <summary>
        /// Saves the entity.
        /// </summary>
        /// <param name="entity">The <see cref="T"/> entity to be saved.</param>
        public void Save(T entity)
        {
            string    location = @"DalEntityBase.Save";
            Stopwatch watch    = Stopwatch.StartNew();

            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            try
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, entity);
                    stream.Seek(0, SeekOrigin.Begin);

                    CloudBlobClient client = this.storageAccount.CreateCloudBlobClient();
                    CloudBlob       blob   = client.GetBlobReference(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}", this.container.Name, this.BlobDirectoryName, entity.Identifier));
                    blob.UploadFromStream(stream);
                }

                this.SaveExtended(entity);
            }
            catch (Exception exception)
            {
                LoggerFactory.Logger.Error(location, EventId.DALSaveEntity
                                           , "Error while saving entity {0} in folder {1} in container {2}: {3}."
                                           , entity.Identifier, this.BlobDirectoryName, this.container.Name, exception.ToString());
                throw;
            }
            finally
            {
                watch.Stop();
                LoggerFactory.Logger.Debug(location, "Save({0}) for type {1} finished in {2} ms.", entity.Identifier, typeof(T), watch.ElapsedMilliseconds);
            }
        }