I am developing an azure application which needs at some point to upload(download) a large amount of small blobs to a single container (more than 1k blobs, less than 1 Mb each). In order to speed up this process I'd like to use multiple threads for uploading(downloading) blobs.
This is routine I use for uploading single blob:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer =
blobClient.GetContainerReference(ContainerName);
blobContainer.CreateIfNotExist();
CloudBlob blob = blobContainer.GetBlobReference(Id);
blob.UploadByteArray(Data);
For each type used in the code above MSDN says following:
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Does it mean that I need to execute following code in every thread? Or maybe I can execute it only once and share single instance of CloudBlobContainer among different threads?
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer =
blobClient.GetContainerReference(ContainerName);
I would be really happy to use single instance of CloudBlobContainer in different threads otherwise it seriously slows down the whole uploading(downloading) process.