public async Task RemovePackageAsync(string packageId, string packageVersion)
        {
            if (packageId == null)
            {
                throw new ArgumentNullException("packageId");
            }
            if (packageVersion == null)
            {
                throw new ArgumentNullException("packageVersion");
            }

            await BlogFilesContainer.GetBlockBlobReference(GetPackageKey(packageId, packageVersion)).DeleteAsync();

            var cachedPackage = Cache[packageId] as IWebPackage;

            if (cachedPackage != null && cachedPackage.Version == SemanticVersion.Parse(packageVersion))
            {
                Cache.Remove(packageId);

                // Load the latest package to Cache
                var packages = BlogFilesContainer.ListBlobs().OfType <CloudBlockBlob>().Select(SafeReadZipPackage).Where(package => package != null).Where(p => p.Id == packageId);
                if (packages.Any())
                {
                    var latestPackage = packages.MaxBy(p => p.Version);
                    if (latestPackage != null)
                    {
                        AddToCache(latestPackage);
                    }
                }
            }
        }
        public AzureBlobPackageRepository(string containerName, string connectionString)
        {
            _packagesBlob     = containerName;
            _connectionString = connectionString;

            _blogFilesContainer = new Lazy <CloudBlobContainer>(
                () =>
            {
                var container = CloudStorageAccount.Parse(_connectionString)
                                .CreateCloudBlobClient()
                                .GetContainerReference(_packagesBlob);

                if (container.CreateIfNotExists())
                {
                    var permissions          = container.GetPermissions();
                    permissions.PublicAccess = BlobContainerPublicAccessType.Container;

                    container.SetPermissions(permissions);
                }

                return(container);
            });


            _lazyMemoryCache = new Lazy <MemoryCache>(
                () =>
            {
                var cache    = MemoryCache.Default;
                var packages = BlogFilesContainer.ListBlobs().OfType <CloudBlockBlob>().Select(SafeReadZipPackage).Where(package => package != null);

                foreach (var package in packages)
                {
                    AddToCache(package, cache);
                }

                return(cache);
            });
        }