1
votes

There is a similar question to this but it was three years ago, no solution given and it used different methods. I have a BlobImageStore.cs file which was eseentially copied from a Microsoft given GitHub sample on using Blob Storage to upload images. This was working without a problem. Went away for a few weeks and am trying to get back to work but now I'm getting this 400 OutOfRangeInput exception. Thought it was filename as I was creating a new Guid to use as the filename which didn't have a problem, but I used the work "test" anyway and still am getting the same exception.

Does anyone have an idea of what the problem could be if I've always been uploading an IFormFile from the stream with the blob name of a new GUID or just a simple name like "test" failing suddenly?

public async Task<Uri> UploadImageToLibraryAsync(Stream stream, string blobName)
        {
            try
            {
                var result = await _containerClient.UploadBlobAsync(blobName, stream);
                return GetBlobUri(_containerClient.GetBlobClient(blobName));
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

I then did a second test where I created a whole new top level client and worked all the way down to downloading a blob. It all worked one by one until I try to download it. At that point I get the same error of OutOfRangeInput.

var test3 = new BlobServiceClient("myConnectionString");
var test4 = test3.AccountName;
var test5 = test3.Uri;
var test6 = test3.GetBlobContainerClient("scrapit-job-images");
var test7 = test6.GetBlobClient("profile_photo.jpg");
var test8 = await test7.DownloadAsync();

Fiddler capture

1
Please trace your request/response through a tool like Fiddler. You should see more details about the error and what exactly is being sent across the wire. Please edit your question and include that information.Gaurav Mantri
@GauravMantri I added the fiddler call but I'm not sure if I'm seeing anything more than what we already know. Same 400-OutOfRangeInput that all the calls I make are getting.Daniel Jackson
Why your account name is in Camel case in your authorization header? It should be all lowercase.Gaurav Mantri

1 Answers

1
votes

I'm able to reproduce this error if the account name is not in all lowercase. Here's the code I used:

const string accountName = "MyStorageAccountName";//Notice the camel case in account name.
const string accountKey = "account-key===";

BlobServiceClient serviceClient = new BlobServiceClient(new Uri("https://MyStorageAccountName.blob.core.windows.net"), new Azure.Storage.StorageSharedKeyCredential(accountName, accountKey));
string containerName = Guid.NewGuid().ToString();
BlobContainerClient containerClient = serviceClient.CreateBlobContainer(containerName);//Throws 400 (One of the request inputs is not valid)

Please try by changing your account name to all lowercase and you should not get this error.