Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:30:08+00:00 2026-05-24T09:30:08+00:00

With windows Azure Storage Client Library, CloudBlob.OpenRead() method reads only 4 mb of data.

  • 0

With windows Azure Storage Client Library, CloudBlob.OpenRead() method reads only 4 mb of data. How can I read full stream using OpenRead method.

CloudBlob blob = container.GetBlobReference(filename);
Stream stream = blob.OpenRead();

I must use OpenRead method. Can’t use DownloadToFile or DownloadToStream.

EDIT :
The consumer code which is outside my scope calls

stream.CopyTo(readIntoStream);

CopyTo is an extension method.

public static int CopyTo(this Stream source, Stream destination)
        {
            byte[] buffer = new byte[BUFFER_SIZE];
            int bytesRead;
            int bytesCopied = 0;

            do
            {
                bytesRead = source.Read(buffer, 0, BUFFER_SIZE);
                if (bytesRead > 0)
                    destination.Write(buffer, 0, bytesRead);
                bytesCopied += bytesRead;
            }
            while (bytesRead > 0);

            return bytesCopied;
        }

EDIT 2 :

I have observed that when file is uploaded using blob.UploadText() method, it works fine but when blob is uploaded using OpenWrite method as done in following code sample, the OpenRead Method reads only 4194304 bytes (4 mb).

using(var input = File.OpenRead(@"C:\testFile.txt")) //5000000 bytes
using (var output = blob.OpenWrite())
{
       input.CopyTo(output);
}

EDIT 3 :

Complete code that produces the issue at my end.

 static void Main(string[] args)
    {
        var blobContainer = GetContainer("tier1");
        blobContainer.CreateIfNotExist();

        var containerPermissions = new BlobContainerPermissions();
        containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;
        blobContainer.SetPermissions(containerPermissions);
        var blob = blobContainer.GetBlobReference("testfileWithOpenWrite1.txt");

        using (var input = File.OpenRead(@"C:\testFile.txt")) //5000000 bytes
        using (var output = blob.OpenWrite(new BlobRequestOptions()))
            input.CopyTo(output);

        Console.WriteLine("uploaded");

        int bytesDownloaded = 0;
        byte[] buffer = new byte[65536];

        using (BlobStream bs = blob.OpenRead())
        {
            int chunkLength;
            do
            {
                chunkLength = bs.Read(buffer, 0, buffer.Length);
                bytesDownloaded += chunkLength;
            } while (chunkLength > 0);
        }

        Console.WriteLine(bytesDownloaded);
    }

    public static int CopyTo(this Stream source, Stream destination)
    {
        int BUFFER_SIZE = 65536;
        byte[] buffer = new byte[BUFFER_SIZE];
        int bytesRead;
        int bytesCopied = 0;

        do
        {
            bytesRead = source.Read(buffer, 0, BUFFER_SIZE);
            if (bytesRead > 0)
                destination.Write(buffer, 0, bytesRead);
            bytesCopied += bytesRead;
        }
        while (bytesRead > 0);

        return bytesCopied;
    }

EDIT 4 – Conclusion:

This was probably a bug in Microsoft.WindowsAzure.StorageClient.dll (assembly version 6.0.6002.17043) that comes with SDK v1.2. It works with latest Microsoft.WindowsAzure.StorageClient.dll (assembly version 6.0.6002.18312 – SDK v1.4).

Thanks smarx 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:30:09+00:00Added an answer on May 24, 2026 at 9:30 am

    I can’t reproduce what you’re seeing. Things seem to work as expected:

    static void Main(string[] args)
    {
        // I also tried a real cloud storage account. Same result.
        var container = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudBlobClient().GetContainerReference("testcontainer");
        container.CreateIfNotExist();
    
        var blob = container.GetBlobReference("testblob.txt");
    
        blob.UploadText(new String('x', 5000000));
    
        var source = blob.OpenRead();
    
        int BUFFER_SIZE = 4000000;
        byte[] buffer = new byte[BUFFER_SIZE];
        int bytesRead;
        int bytesCopied = 0;
        do
        {
            bytesRead = source.Read(buffer, 0, BUFFER_SIZE);
            bytesCopied += bytesRead;
        } while (bytesRead > 0);
    
        Console.WriteLine(bytesCopied); // prints 5000000
    }
    

    EDIT:

    I’ve also (in response to the edited question) now tried uploading the blob using OpenWrite, and the result is the same. (I get the full blob back.) I used this code in place of blob.UploadText(…):

    using (var input = File.OpenRead(@"testblob.txt")) //5000000 bytes
    using (var output = blob.OpenWrite())
    {
        input.CopyTo(output);
    }
    

    The final WriteLine still prints 5000000.

    EDIT 2:

    This is getting a bit tiresome. Changing the BUFFER_SIZE to 65536 didn’t change anything. The results still seem correct to me. Here’s my full application for comparison:

    static void Main(string[] args)
    {
        // I also tried a real cloud storage account. Same result.
        var container = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudBlobClient().GetContainerReference("testcontainer");
        container.CreateIfNotExist();
    
        var blob = container.GetBlobReference("testblob.txt");
    
        using (var input = File.OpenRead(@"testblob.txt")) //5000000 bytes
        using (var output = blob.OpenWrite())
        {
            input.CopyTo(output);
        }
    
        var source = blob.OpenRead();
    
        int BUFFER_SIZE = 65536;
        byte[] buffer = new byte[BUFFER_SIZE];
        int bytesRead;
        int bytesCopied = 0;
        do
        {
            bytesRead = source.Read(buffer, 0, BUFFER_SIZE);
            bytesCopied += bytesRead;
        } while (bytesRead > 0);
    
        Console.WriteLine(bytesCopied); // prints 5000000
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to download data from windows azure table storage back to a SQL
I develop asp.net websites, and I read about cloud computing, windows azure, etc. But
I am using Windows Azure Table Storage. I am wondering, if I could use
I just watched the Windows Azure intro video and it left me feeling like
I am getting to grips with Windows Azure. I usually use NInject as my
I just got my azure invitation code...yay! Are there any official samples for windows
Windows Forms allows you to develop Components, non-visual elements that can have a designer.
I want to use blob-leasing mechanism in my Windows Azure cloud app. I am
I am interested in the best practices to access Windows Azure API from a
I'm dipping my toes into Windows Azure, and I'm running into something that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.