Cannot upload to azure Blob Storage: The remote server returned an error: (400) Bad Request

前端 未结 6 2153
星月不相逢
星月不相逢 2021-02-19 16:48

I\'m trying to create a utility to download file from the internet and upload it again to Azure blob storage. Blob containers already created well; But for some reason i\'m get

相关标签:
6条回答
  • 2021-02-19 17:02

    Have you tried creating a container manually on azure portal? It has some limitations on what name you can give containers.

    For example: Container name cannot contain upper case letters.

    If you request a container with an invalid name, it will result in (400) Bad Request, which you are getting. So check your "containerName" string.

    0 讨论(0)
  • 2021-02-19 17:07

    I also got this error with the Azure Storage Message Queues.

    The Azure Storage Message Queue names must also be all lowercase. ie: "newqueueitem" name in lowercase.

    // Retrieve a reference to a queue.
    CloudQueue queue = queueClient.GetQueueReference("newqueueitem");
    
    // Create the queue if it doesn't already exist.
    queue.CreateIfNotExists();
    
    0 讨论(0)
  • 2021-02-19 17:08

    I had a very different case of bad request message. Posting here for anyone else who may hit the same. In my case, I was just moving around resource across other resource groups . In that shuffling, a bug in azure allowed me to point my storage to location ("South East Asia") which was not available in my region. So all requests against the storage account returned the bad request message. It took me a while to figure this out because I then created another storage account to test, which when creating, azure did not allow me to pick "South East Asia" as a location of choice, so I picked another location ("East Asia") and then everything worked fine.

    0 讨论(0)
  • 2021-02-19 17:09

    I had the same problem. I resolved it by changing the TLS version in the configuration of the storage; the new TLS version (1.2) is not compatible with the older version of the storage client. I changed it to the 1.0 and it works.

    The configuration of the storage is in the portal of Azure.

    Storage -> Configuration -> TLS Version:

    storage configuration in portal

    0 讨论(0)
  • 2021-02-19 17:15

    If you create a container with an invalid name, it will result in (400) Bad Request. There are some convention for creating container name as below:

    1. Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
    2. Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names.
    3. All letters in a container name must be lowercase.
    4. Container names must be from 3 through 63 characters long.

    Source: https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata

    0 讨论(0)
  • 2021-02-19 17:19

    I faced the same issue while creating the queue in Azure with one UpperCase Letter from my C# code. The error was with the Queue Name. All the characters should be lowercase. After changing all the characters to lowercase it worked! :)

    //Retrieve a reference to a queue
    CloudQueue queue = queueClient.GetQueueReference("myqueue");
    //Create a queue if it alredy doen't exists
    queue.CreateIfNotExists();
    
    0 讨论(0)
提交回复
热议问题