Thanks in advance for any help.
I have a string that I create programmatically in C# that I want to persist to Azure BLOB storage. I build the string in code, then attempt to store it as the final step (a text file). All works well until my string becomes a certain size. The process truncates the string at a point. The file gets created, but the overflow amount is simply chopped off. It seems that I need to break the operation into chunks, but I'm not quite sure how to get there. I'm thinking I need to read through the string and then insert in chunks.
I'm using the Azure Management Libraries. Here is my code:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(MyString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudContainer = blobClient.GetContainerReference(DestinationContainerName);
cloudContainer.CreateIfNotExists();
CloudBlockBlob blockBlob = cloudContainer.GetBlockBlobReference(DestinationFileName);
blockBlob.UploadText(sTheFile)
The variable "sTheFile" is the string that appears to be too large.
I do need to use UploadText as the file is being built virtually in code. Does anyone know how to parse through my string (stheFile) and create the BLOB in chunks?
Sincere thanks...
Block blobs are limited to 64MB for a single upload and the storage client defaults to 32MB which you can increase to 64MB by setting SingleBlobUploadThresholdInBytes.
For blobs above that size you will need to convert the string to a MemoryStream and use PutBlock to send it in blocks.
The article at this link shows how to do that:
Windows Azure - BlockBlob PutBlock Method