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

Windows Azure Data Services supports a subset of TSQL. What are the features of
Can I host an application in Windows Azure and have the database stored on
I am using Windows Azure Table Storage. I am wondering, if I could use
I am working with Windows Azure and am just using the Blob Storage. I
The Windows Azure Storage Abstractions and their Scalability Targets blog post indicates there is
I have a Windows Azure application in which all read queries of TableA are
I now have my Windows Azure environment set up so that I can access
I'm working with Windows Azure Table Storage and have a simple requirement: add a
What options are there to secure Windows Azure Table storage? Is there anyway to
EDIT: Is it possible to use Entity Framework with Windows Azure development storage service?

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.