locked
Azure Storage Timeout with Windows Phone 8.1 RRS feed

  • Question

  • Hi

    I have written a universal app for Windows / Windows Phone 8.1.  As part of this I have the ability to upload a file to an azure blob storage.

    What I am finding is that I am only able to upload incredibly small files to azure.  If I have a 1-2kb .txt file the process takes milliseconds to complete on both windows 8.1 and WP8.1.  If I select a larger .txt file - or a .jpg which is the intended use - of say 70kb then the upload will not complete on Windows Phone 8.1.  On Windows 8.1 it completes in milliseconds again.

    I don't think its a bandwidth issue with my phone, I've tried connecting with the same wifi as my pc etc and even on cellular I have 4G running at 10Mb/s upload.

    In the code snippet below I'm hardcoding the file for testing. 

    public static async Task UploadBlobWP(string fileName, string blobUrl, string containerName)
            {
    
                var sasUri = new Uri(blobUrl);
    
                StorageCredentials credentials = new StorageCredentials(sasUri.Query.Substring(1));
    
                CloudBlobContainer container = new CloudBlobContainer(new Uri(string.Format("https://{0}/{1}", sasUri.Host, containerName)), credentials);
    
                CloudBlockBlob blobFromSASCredential = container.GetBlockBlobReference(fileName);
                StorageFile tmpfile = await Settings.Setting.applicationData.LocalFolder.GetFileAsync("tmp2.jpg");
                
                using (var stream = await tmpfile.OpenStreamForReadAsync())
                {
                    await blobFromSASCredential.UploadFromStreamAsync(stream);
                }
    
            }

    Edit: Above is the upload code I'm using,  the SAS etc is coming from the azure sql insert side similar to http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-phone-upload-data-blob-storage/ This doesn't seem to be the issue as the very small files and larger files on pc work fine.

    ---------------------------------------------------

    Error Received after ~5 minutes

    +  $exception {Microsoft.WindowsAzure.Storage.StorageException: The client could not finish the operation within specified timeout. ---> System.TimeoutException: The client could not finish the operation within specified timeout.
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.Storage.Core.Util.StorageAsyncResult`1.End()
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndUploadFromStream(IAsyncResult asyncResult)
       at System.Action`1.Invoke(T obj)
       at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.<CreateCallbackVoid>b__3(IAsyncResult ar)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at BlueDot.Camera.<UploadBlobWP>d__21.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at BlueDot.Camera.<Capture_Clicked>d__13.MoveNext()
    Request Information
    RequestID:
    RequestDate:
    StatusMessage:
    } System.Exception {Microsoft.WindowsAzure.Storage.StorageException}

    --------------------------------------------------------------------------------------------

    I have checked everything I could think of,  the stream looks good at the right length (varying on file) and the position is always set to 0.

    Are there any known limitations with WP8.1 and Azure Storage?  Has anyone successfully written a blob upload targeted at WP8.1 and had/overcome this issue.

    Thanks

    Daniel



    • Edited by D_Read Thursday, August 14, 2014 12:37 AM
    Thursday, August 14, 2014 12:28 AM

All replies

  • How are you calling UploadBlobWP? Is it awaited?
    Thursday, August 14, 2014 1:01 AM
  • Hi Serdar thanks for the reply.

    Exactly the UploadBlobWP is awaited in the code.  I've included some more context of the code below,  if needed I can supply a simple solution as an example?

    //Create the file object and set blob filename
    FileLocations tmp = new FileLocations();
    Guid filename = Guid.NewGuid();
    tmp.FileName = filename + ".jpeg";
    
    //Upload the file object to azure
    MobileServiceClient MobileService = new MobileServiceClient("https://XXXXX.azure-mobile.net/", "YYYYYYYYYYYYYYY");
    IMobileServiceTable<FileLocations> fileLocationTable = MobileService.GetTable<FileLocations>();
    
    await fileLocationTable.InsertAsync(tmp);
    
    //We now have the tmp.FileUrl value completed as this is created on azure side in azure insert jscript.
    
    await UploadBlobWP(tmp.FileName, tmp.FileUrl, "picture");

    Thanks

    Daniel

    Thursday, August 14, 2014 5:47 AM
  • And how is this code called? The reason I am asking is to see whether there is any blocking calls throughout the stack.

    Thursday, August 14, 2014 9:09 PM
  • This code is contained directly under a Button Click event function.

    I will simplify the code and reference new azure services and supply a sample solution.  I do not believe I have a blocking issue but will be happy if I have made an error :)

    Thursday, August 14, 2014 11:34 PM