BlobStorage.Advanced.CreateSampleContainerAsync C# (CSharp) Method

CreateSampleContainerAsync() private static method

Creates a sample container for use in the sample application.
private static CreateSampleContainerAsync ( Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient ) : Task
blobClient Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient The blob service client.
return Task
        private static async Task<CloudBlobContainer> CreateSampleContainerAsync(CloudBlobClient blobClient)
        {
            // Name sample container based on new GUID, to ensure uniqueness.
            string containerName = ContainerPrefix + Guid.NewGuid();

            // Get a reference to a sample container.
            CloudBlobContainer container = blobClient.GetContainerReference(containerName);

            try
            {
                // Create the container if it does not already exist.
                await container.CreateIfNotExistsAsync();
            }
            catch (StorageException e)
            {
                // Ensure that the storage emulator is running if using emulator connection string.
                Console.WriteLine(e.Message);
                Console.WriteLine("If you are running with the default connection string, please make sure you have started the storage emulator. Press the Windows key and type Azure Storage to select and run it from the list of applications - then restart the sample.");
                Console.ReadLine();
                throw;
            }

            return container;
        }