Home » c# » c# – Azure Blob Storage Update-Exceptionshub

c# – Azure Blob Storage Update-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment


I am trying to read the content from Azure BlockBlob, apply some transformation and write the content back to the same blob in Azure Function.

The code is below for writing the content back. It runs success. However, when I examine the content in the final blob, it only has partial of the data. e.g. there should be 28 rows of data in the content, but the content only has 26 and half rows, it seems the part of content get lost after calling “UploadFromStreamAsync”. I see lost of examples on the web but they are all about uploading brand new files. Am I missing something in the code when updating blob?

    protected async Task WriteItemsToBlog(string blobName, List<T> items)

        var cloudStorageAccount =
            new CloudStorageAccount("MyStorageCredentials", "MyAccountName", null, true);

        var cloudBlobClient =

        var cloudBlobContainer =

        var cloudBlockBlob =

        var ms = new MemoryStream();

        using (var writer = new StreamWriter(ms))
        using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
            ms.Position = 0;
            cloudBlockBlob.Properties.ContentType = "text/plain";

            await cloudBlockBlob.UploadFromStreamAsync(ms, ms.Length);
How to&Answers: