Example #1
0
        /// <summary>
        /// Container Owners for Azure Blob cannot defy the naming conventions.
        /// (alphanumeric, all lowercase, & dashes only)
        /// </summary>
        /// <param name="application"></param>
        /// <returns>Async task that can be awaited</returns>
        public async Task InitializeRootFolder(string folder)
        {
            // Make folder abide by ContainerRuleConvention
            folder = ContainerRuleConvention(folder);

            // Get Cloud Storage Account, then blobclient, then container
            CloudStorageAccount cloudStorageAccount = CloudHelper.GetConnectionString();
            CloudBlobClient     cloudBlobClient     = cloudStorageAccount.CreateCloudBlobClient();

            cloudBlobContainer = cloudBlobClient.GetContainerReference(folder);
            if (await cloudBlobContainer.CreateIfNotExistsAsync())
            {
                await cloudBlobContainer.SetPermissionsAsync(new BlobContainerPermissions
                {
                    PublicAccess = BlobContainerPublicAccessType.Blob
                });
            }
        }