locked
Bad request error(400) on using uploadText function to write a new file RRS feed

  • Question

  • Hi All,

    I am new to Azure and C#. I have a requirement to get the message from service bus, do some manipulations and write as a new file in Azure file share directory. I am not able to do the last part of creating the file since I am getting the below exception.

    Exception while executing function: Functions.ProcessQueueMessage
    Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProcessQueueMessage ---> Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
    // Create a CloudFileClient object for credentialed access to File storage.
    CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
    // Get a reference to the file share we created previously.
    CloudFileShare share = fileClient.GetShareReference("existingFS");
    // Ensure that the share exists.
    if (share.Exists())
    {
    // Get a reference to the root directory for the share.
    CloudFileDirectory rootDir = share.GetRootDirectoryReference();
    // Get a reference to the directory we created previously.
    CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("testDir");
    // Ensure that the directory exists.
    if (sampleDir.Exists())
    {
    CloudFile file = sampleDir.GetFileReference(lastLine);
    file.file.UploadText(stringMsg);//I have value in stringMsg
    }
    }

    What am I missing here. Could some one please help.


    • Edited by abhi17 Wednesday, March 15, 2017 5:39 PM editing
    Wednesday, March 15, 2017 5:38 PM

All replies