public async Task UploadFolderToBlob(string path, BlobContainerType containerType)
        {
            var    provider = new FileExtensionContentTypeProvider();
            string contentType;

            CloudBlobContainer coreContainer = await GetContainer(containerType);

            IEnumerable <string> files = Directory.EnumerateFiles(path, "*", new EnumerationOptions()
            {
                RecurseSubdirectories = true
            });

            int substringStart = path.Length;

            foreach (string file in files)
            {
                CloudBlockBlob blob = coreContainer
                                      .GetBlockBlobReference(file.Substring(substringStart).TrimStart('\\').Replace('\\', '/'));

                if (!provider.TryGetContentType(file, out contentType))
                {
                    contentType = "application/octet-stream";
                }

                blob.Properties.ContentType = contentType;

                blob.UploadFromFile(file);
            }
        }
        public async Task <string> GetBlobAsString(string path, BlobContainerType containerType)
        {
            CloudBlobContainer coreContainer = await GetContainer(containerType);

            CloudBlockBlob blob = coreContainer.GetBlockBlobReference(path);

            return(await blob.DownloadTextAsync());
        }
        private string GetContainerSecretURL(BlobContainerType containerType)
        {
            switch (containerType)
            {
            case BlobContainerType.Public:
                return(Config.PublicStoreSecretURL);

            case BlobContainerType.Internal:
                return(Config.InternalStoreSecretURL);

            default:
                throw new ArgumentOutOfRangeException("No known secret url to get the container type connection string");
            }
        }
        private async Task <CloudBlobContainer> GetContainer(BlobContainerType containerType)
        {
            if (_cachedCoreContainer != null && DateTimeOffset.Now > _cachedCoreContainerExpiry)
            {
                return(_cachedCoreContainer);
            }

            string storageConnectionString = await KeyVaultHelper.GetSecret(GetContainerSecretURL(containerType));

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);

            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            _cachedCoreContainer       = blobClient.GetContainerReference("core");
            _cachedCoreContainerExpiry = DateTimeOffset.Now.AddHours(1);

            return(_cachedCoreContainer);
        }