Mark Chidlow
Mark Chidlow

Reputation: 1472

Azure blob storage access - no exceptions but no write

I'm attempting to store a file in Azure Blob storage - I get no exceptions but the file does not appear. I am obviously doing something wrong. I have a basic test as follows:

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=mystorage1;AccountKey=1xxxxxusCw==");
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer container = blobClient.GetContainerReference("myimagecontainer");
            CloudBlockBlob blob = container.GetBlockBlobReference($"image.jpg");

            using (var fileStream = System.IO.File.OpenRead(@"C:\temp\image.jpg"))
            {
                blob.UploadFromStreamAsync(fileStream);
            }

Access Type is 'Blob'.

Any ideas why this would not work (obviously I have changed the account info etc)?

Thanks

Upvotes: 0

Views: 377

Answers (1)

Stephen McDowell
Stephen McDowell

Reputation: 959

The possible error is not being handled because of the async. Try awaiting the upload and/or double check how exceptions are being handled.

Upvotes: 1

Related Questions