CreateIfNotExists error 400

Jim Durbin 6 Reputation points
2022-06-14T01:04:42.78+00:00

Can't tell what is producing this error. Used Azure Storage Explorer to confirm the Account and blob directory (server NOT emulated - data is on an external Azure server) copied from the vb code - can see the account, the blob storage container directories, and their contents. Don't see any issue with Name, key, blob directory.

How do I diagnose this issue? Is it an issue with a wrong library? There are no compilation or warning errors in the vb project. No answers on the web so far.

Using:
Azure Core 1.24
Azure.Storeage.Blobs 12.12.0
Azure.Storage.Common 12.11.0
Microsoft.Azure.Functions.Extensions 1.1.0
Microsoft.Windows.Azure.SDK 2.9.0
WindowsAzure.Storage 9.3.3

I am not sure which of the above are actually called by the CreatIfNotExists code.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Jim Durbin 6 Reputation points
    2022-06-18T16:01:38.5+00:00

    This is resolved thanks to MS developer level tech support

    The call to CloudBlobClient.GetContainerReference had too much info in it and simply needed to be trimmed down to nothing but the actual container name instead of including the Azure portal address full string.. Unfortunately the documentation only says that the calling parameter be a string, with no guidance on format restrictions. And further, the error 400 message could have been more explicit, indicating what parameter was wrong, but is deficient in this respect. I would highly recommend that the error reporting be enhanced.

    1 person found this answer helpful.
    0 comments No comments

  2. Jim Durbin 6 Reputation points
    2022-06-14T15:17:14.173+00:00

    This is the code that is failing

        Dim Step1 As Int16 = 0  
        Dim filepath As String = "" ' Trim(FileToUpload.Text)  
        Dim container As CloudBlobContainer  
        Dim storageAccount As Microsoft.WindowsAzure.Storage.CloudStorageAccount  
        Dim blobclient As CloudBlobClient  
        Dim blockBlob As CloudBlockBlob  
        Try  
    
            Step1 = 2  
            storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=myaccountjwd;AccountKey=mykeyjwd==")  
    
            Step1 = 4  
            blobclient = storageAccount.CreateCloudBlobClient()  
    
            Step1 = 6  
            container = blobclient.GetContainerReference("https://myaccountjwd.blob.core.windows.net/btb-patches/")  
    
            Step1 = 8  
            filename = Mid(Trim(FileToUpload.Text), InStrRev(Trim(FileToUpload.Text), "\") + 1)  
            filename = filename.ToLower()  
    
            Step1 = 9  
            blockBlob = container.GetBlockBlobReference(filename) ' put the filename into the blockBlob  
    
            Step1 = 10  
            container.CreateIfNotExists()  
    
        Catch ex As Exception  
            MsgBox("error in UploadToAzure_click at step " + Step1.ToString + Chr(10) + "error code = " + Err.ToString + Chr(10) + ex.Message)  
            OK = False  
        End Try  
     
    

    The code fails at step 10. FileToUpload.Text is a screen field pointing to a valid zip file with valid access on this machine.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.