locked
Winzows Azure BLOB and LocalResource Issues RRS feed

  • Question

  • Hi!

            

     I am novice in Azure.  

    // below code is working fine for small file uploading. But when uplaoding large file it gives timeout expiration error.

    public string ConvertVideoFromBlob()
            {
                string inputName =hidden_filename.Value;
                LocalResource localResource = RoleEnvironment.GetLocalResource("localStore");
                string[] paths = { localResource.RootPath, inputName };
                String filePath = Path.Combine(paths);
                CloudStoreAc_obj = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=xxxxxx;AccountKey=xxxxxxxxxxxxxxxxxxxxxxx");
                CloudBlobClnt_obj = CloudStoreAc_obj.CreateCloudBlobClient();
                CloudBlobClnt_obj.Timeout = new System.TimeSpan(0, 15, 0);
                CloudBlobCont_obj = CloudBlobClnt_obj.GetContainerReference("container1");
                CloudBlobCont_obj.CreateIfNotExist();
                try
                {
                    CloudBlobCont_obj.GetBlobReference(inputName).DownloadToFile(filePath);  //<----my problem is hear (DownloadToFile(filePath))
                }                                                                                                                            //If i use downloadtosteam() then it  gives error
                catch
                {
                    lbl_convertInfo.Text = " Network connection timeout.";
                }
                string input_file = localResource.RootPath + inputName;
                string delimated_filename = inputName.Substring(inputName.LastIndexOf('_') + 1);
                int last_dot_index = delimated_filename.LastIndexOf('.');
                string file_without_ext = delimated_filename.Substring(0, last_dot_index);
                string convertedFilename = Guid.NewGuid().ToString() + "_" + file_without_ext + ".flv";
                 string output_file = localResource.RootPath + convertedFilename;
                string sites_root = HttpContext.Current.Server.MapPath(@"~\");
                sites_root = Path.Combine(sites_root + @"\", @"VideoConverter\ffmpeg.exe");
                proc = new Process();
                try
                {
                    proc.StartInfo.UseShellExecute = false;
                    proc.StartInfo.CreateNoWindow = true;
                    proc.StartInfo.FileName = sites_root;
                     proc.StartInfo.Arguments = " -i \"" + input_file + "\" -qmax 10 -ar 22050 \"" + output_file;
                     proc.StartInfo.RedirectStandardError = true;
                    proc.StartInfo.RedirectStandardOutput = true;
                    proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(proc.StartInfo.FileName);
                     proc.Start(); // start !
                    string StdErrVideo = proc.StandardError.ReadToEnd();
                    proc.WaitForExit();
                    proc.Close();
                    FileStream fs = File.OpenRead(output_file);
                    CloudBlobCont_obj.GetBlobReference(convertedFilename).UploadFromStream(fs);
                    hidden_convertedFile.Value = convertedFilename;
                    return "1";
                }


                catch (Exception ex)
                {
                    Response.Write(ex.ToString());
                    return "0";
                }
                finally
                {

                    proc.Close();

                }

              }

    Please help me. Thanks 

    Monday, February 27, 2012 1:31 PM

Answers

  • Hi - ok, so before we get to the question of block lists or not (since that's during upload, and your problem is during the download), let's find out the download problem.

    In your code, I had a couple questions:
    1) Before you get the blob, you call "CreateIfNotExist" on the container - are you sure the blob exists?  Just making sure!
    2) you have a generic "Catch", which just sets your label to timeout.  However, there are far more exceptions that could have happened.  Can you change to "catch (Exception ex)" and post the exception type and message here?
    3) Related - is the timeout happening after 15 minutes?  You're setting your timeout to 15 minutes, which should be ok.  But if the exception is happening before 15 minutes, then it's probably not a timeout.  If it is happening after 15 minutes, then check your download speed (use task manager or other bandwidth monitoring tool) - 50MB in 15 minutes is 400-500Kbps.  If that's the speed of your download, then you will simply need to increase your timeout.

    Let me know what you find, and hopefully we can get this working for you.


    -Jeff

    • Marked as answer by Arwind - MSFT Friday, March 9, 2012 10:50 AM
    Monday, March 5, 2012 6:46 PM

All replies

  • your problem is upload / download?

    i would recommend you to upload using PutBlockList for big files. for more detail, visit here.


    Regards, Wely Lau http://wely-lau.net (Wordpress on Windows Azure)

    Monday, February 27, 2012 4:00 PM
  • Thanks for the question - can you provide more information?

    1) Are you having a problem with uploading or downloading?  The top comment says uploading, but the code highlighted is for downloading.
    2) What is the error you are getting?
    3) What size is the "small" file, and what size is the "large" file?  Does the small one ever fail?  Does the large one ever succeed?

    Thanks!


    -Jeff

    Monday, February 27, 2012 6:52 PM
  • Hi!

    Thanks for quick response!

    Please find my comments:

    1)--> I am getting problem when downloading.

    2)--> Time out expiration error.

    3)--> Some time I got error to download 20 mb small file . large files are  50mb+ . All are video files.

    Thanks

    Friday, March 2, 2012 9:44 AM
  • Hi,

    The task I am doing is:

    step1--> downloading video from blob to local resource

    step2-> convert the downloaded file  into streaming video format

    step3-->again upload the converted file ton blob.


    Thanks

    Friday, March 2, 2012 9:53 AM
  • Hi - ok, so before we get to the question of block lists or not (since that's during upload, and your problem is during the download), let's find out the download problem.

    In your code, I had a couple questions:
    1) Before you get the blob, you call "CreateIfNotExist" on the container - are you sure the blob exists?  Just making sure!
    2) you have a generic "Catch", which just sets your label to timeout.  However, there are far more exceptions that could have happened.  Can you change to "catch (Exception ex)" and post the exception type and message here?
    3) Related - is the timeout happening after 15 minutes?  You're setting your timeout to 15 minutes, which should be ok.  But if the exception is happening before 15 minutes, then it's probably not a timeout.  If it is happening after 15 minutes, then check your download speed (use task manager or other bandwidth monitoring tool) - 50MB in 15 minutes is 400-500Kbps.  If that's the speed of your download, then you will simply need to increase your timeout.

    Let me know what you find, and hopefully we can get this working for you.


    -Jeff

    • Marked as answer by Arwind - MSFT Friday, March 9, 2012 10:50 AM
    Monday, March 5, 2012 6:46 PM