locked
inconsistent in file upload process RRS feed

  • Question

  • I have a file upload method for Azure blob storage. code as below

                                                                                                                                                                         

    CloudStorageAccount cloudStorageAccount;
                    CloudBlobClient blobClient;
                    CloudBlobContainer blobContainer;
                    BlobContainerPermissions containerPermissions;
                    CloudBlob blob;

                    cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["CLOUDSTORAGE_ACCOUNT"]);

                    blobClient = cloudStorageAccount.CreateCloudBlobClient();


                    blobContainer = blobClient.GetContainerReference(fileType);

                    blobContainer.CreateIfNotExist();                

                    containerPermissions = new BlobContainerPermissions();

                    containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;
                    blobContainer.SetPermissions(containerPermissions);


                    blob = blobContainer.GetBlobReference(FileName);



                    blobClient.ParallelOperationThreadCount = 2;


                    IAsyncResult result = blob.BeginUploadFromStream(InputStream, null, null, null);
                    blob.EndUploadFromStream(result);

    Which is working fine in local but once hosted as Azure application , file upload is throwing error as :

    The server encountered an unknown 
       failure: The underlying connection was closed: 
       Could not establish trust relationship for the SSL/TLS secure channel. 

    After some time it will work fine.  Can you help me exactly what may be wrong

    Thursday, April 23, 2015 7:55 AM

Answers

  • Hi Srinivas,

    We can see that you are facing two issues:

    • Thread abort: The thread abort can occur for many reasons.  Likely this will need some additional traces taken on your VM.
    • Could not establish trust relationship for the SSL/TLS secure channel: For the SSL error there is likely an issue with the certificate that you are using for your storage account.

    In this case you will need to open a Technical support incident with Microsoft so we can assist you further.

    Regards,
    Malar.

    Friday, May 8, 2015 5:31 AM

All replies

  • Hi Srinivas,

    Have you checked if there is a problem in the system time syncing to the time servers?
    If its is a sync issue, to correct it, you could:

    • Right-click the clock in the task bar
    • Select Adjust Date/Time
    • Select the Internet Time tab
    • Click Change Settings
    • Select Update Now

    There might be an issue with the SSL certificate as well.
    Are you using a self signed certificate? Do the host name between the certificate and the server match?
    You could try overriding the client certificate (This is dangerous if you are calling a server outside of your direct control, since you can no longer be as sure that you are talking to the server you think you're connected to.) You could try the following code:

     //Trust all certificates
                System.Net.ServicePointManager.ServerCertificateValidationCallback =
                    ((sender, certificate, chain, sslPolicyErrors) => true);

    Also for details you could refer the following links, where the customers are facing similar issues:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/bb0fc194-5bf3-4c24-94bb-c86f94c76bc2/could-not-establish-trust-relationship-for-the-ssltls-secure-channel-with-authority-pc1?forum=wcf

    http://stackoverflow.com/questions/703272/could-not-establish-trust-relationship-for-ssl-tls-secure-channel-soap

    Regards,
    Malar.

    Thursday, April 23, 2015 1:03 PM
  • Hi

     All our servers are in South East Asia Zone.

    Some times we are getting thread aborting and few times we are getting cannot establish trust relationship for SSL/TLS secure channel.

    We are using the SSL certifate only on report click. No where we are using certificate on file upload in the application.

    It worked fine in the past 4 days an today again we are having same issue.

    Is it something that one of the physical server of Azure is creating this, what else i can try.

    Thanks,

    Srinivas


    Monday, April 27, 2015 4:42 AM
  • Hi Srinivas,

    I'm afraid, You are using an old Azure Storage Library. We would suggest you upgrade the Azure .NET Storage Library via NuGet or as part of the Azure SDK for .NET 2.5.1.

    Please follow this article for more information.

    http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

    As a result of the upgrade, many namespaces, classes and methods have changed for both sync and async methods.

    Please follow the sample in the article above and let us know how it works. It has samples for both sync and asycn calls.

    Regards,
    Malar.

    Wednesday, April 29, 2015 3:38 PM
  • Hi, 

    IS any web.config content that will impact Azure app

    We are using the latest one only and for my strange, the same code published in Azure-1(UAT) environment is working fine but not in Azure-2(prod).

    Is there any setting in Azure application server that may impact blob file upload.

    Thread is getting aborted at ' blobContainer.CreateIfNotExist();  ' piece of code.

    Stack Trace:

    StackTrace   at System.Threading.WaitHandle.WaitOneNative(SafeHandle waitableSafeHandle, UInt32 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
       at System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
       at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext)
       at System.Threading.WaitHandle.WaitOne()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
       at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry[T](Func`2 impl, RetryPolicy policy)
       at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist(BlobRequestOptions options)
       at Handler.ProcessRequest(HttpContext context) 

    Thanks,

    Srinivas




    Wednesday, May 6, 2015 2:49 AM
  • Hi Srinivas,

    We can see that you are facing two issues:

    • Thread abort: The thread abort can occur for many reasons.  Likely this will need some additional traces taken on your VM.
    • Could not establish trust relationship for the SSL/TLS secure channel: For the SSL error there is likely an issue with the certificate that you are using for your storage account.

    In this case you will need to open a Technical support incident with Microsoft so we can assist you further.

    Regards,
    Malar.

    Friday, May 8, 2015 5:31 AM