locked
Timeout occuring while uploading blobs to Azure Storage "Operation could not be completed within the specified time." RRS feed

  • Question

  • Hi

    I am tryig top upload the 7MB file to Blob but I am getting the exception 

    "Operation could not be completed within the specified time."

    I am able to upload the small files but not able to upload the 7MB file..

    Code is below.(It was working fine few days back but today it is not working fine )

    private static List<string> ExportPackageToContainer(string dirPath)
            {
                List<string> packageURI = new List<string>();

                // Retrieve storage account information from app.config file (uses dev storage by default).
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                    ConfigurationManager.AppSettings["StorageAccountConnectionString"]);

                // Create client object for Blob service.
                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                // Get container name corresponding to top-level folder name  
                string containerName = "packages";
                Console.WriteLine("Uploading blobs to container " + containerName);

                // Get named container or create if it does not exist.
                CloudBlobContainer container = GetContainer(blobClient, containerName, true);

                // Controlling
                BlobContainerPermissions per = new BlobContainerPermissions();
                per.PublicAccess = BlobContainerPublicAccessType.Off;
                container.SetPermissions(per);

                // Create a blob for each file in the top-level directory and all subdirectories.
                foreach (string fileName in Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories))
                {
                    // Exclude hidden, system, and temp files
                    if (0 == (new FileInfo(fileName).Attributes &
                        (FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary)))
                    {

                        if ((fileName.Substring(fileName.Length - 5) != "cspkg"))
                        {
                            continue;
                        }

                        // Construct the blob reference from the top level folder path and file name.
                        CloudBlob blob = container.GetBlobReference(fileName.Substring(dirPath.Length + 1));

                        // Upload the file to the blob.
                        try
                        {
                            //     blob.UploadFile(fileName);
                            var fileStream = System.IO.File.OpenRead(@fileName);
                            blob.UploadFromStream(fileStream);
                            packageURI.Add(blob.Uri.ToString());
                            Console.WriteLine("Uploaded" + blob.Uri);
                        }
                        catch (StorageClientException e)
                        {
                            Console.WriteLine("Could not upload blob named " + blob.Uri);
                            Console.WriteLine("Error message: " + e.Message);
                        }
                    }
                }
                return packageURI;
            }

    Tuesday, August 28, 2012 5:54 AM

Answers

  • Issue resolved .. Increased the default timeout from 90 sec to 600 sec..

    Thanks

    Tuesday, August 28, 2012 6:34 AM