Example #1
0
        public virtual async Task <BlobContainer> GetContainerReferenceAsync(string containerName)
        {
            Utility.AssertNotNullOrEmpty(nameof(containerName), containerName);
            var response = await ContainersApiClient.GetContainerByNameAsync(containerName);

            if (response.ResponseMessage.IsSuccessStatusCode == false)
            {
                if (response.ResponseMessage.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    throw ExceptionGenerator.ContainerNotFoundException($"Container {containerName} not found.");
                }

                throw ExceptionGenerator.GeneralFailureException(response.StringContent);
            }

            var containerDTO = response.GetContent();

            return(new BlobContainer(containerDTO.Name, containerDTO.Id, this));
        }