locked
UploadFromStream not working with error "Unable to connect to the remote server" RRS feed

  • Question

  • I have a ASP.Net webapi that uploads files (blobs) to Azure storage.  The code works on dev machine. But I cannot get it to work on other boxes (Windows Server 2012). 

    I get an error "Unable to connect to the remote server" when I call this method.

    Is there a setting in IIS that I need to do ?

    I have a testapi, that gives me the container name and that works. So it's not a problem connecting to Azure.

    I can use Powershell cmdlet "Set-AzureStorageBlobContent" and that works and the same file gets uploaded to my blob.

    Can somebody give me pointers to troubleshoot this issue ?

    Wednesday, August 5, 2015 7:48 PM

Answers

  • Please specify DefaultEndpointsProtocol=http;AccountName=myAccount;AccountKey=myKey; in your connection string.
    Friday, August 7, 2015 11:58 PM

All replies

  • Hi,

    Is Windows Server 2012 an Azure Virtual machine chosen from the gallery that's not getting connected to ?

    Though you said its not a problem connecting to azure, As per the error message it appears that the account that you are using to connect does not have Remote Desktop logon rights. Ensure that the account you are using to initiate the connection has Remote Desktop logon rights.

    Could you share the exact error message for further analysis.

    Regards,

    Shirisha Paderu

    Thursday, August 6, 2015 10:23 AM
  • This is a Windows Server 2012 sitting in my datacenter.

    Here's the complete exception, I am getting

     Microsoft.WindowsAzure.Storage.StorageException: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 168.61.131.14:443
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
       --- End of inner exception stack trace ---
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromStreamHelper(Stream source, Nullable`1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
       at UploadFiles.Controllers.UploadFileController.UploadBlobSync(CloudBlobContainer cloudBlobContainer, String fileName, Stream stream)

    Thursday, August 6, 2015 1:02 PM
  • Looks like 168.61.131.14:443 is blocked.

    Is there a way I can use proxy settings with an Azure connection ?

    It's weird that Set-AzureStorageBlobContent works, doesn't that use the same port?
    • Edited by RoshDsa Thursday, August 6, 2015 1:46 PM
    Thursday, August 6, 2015 1:42 PM
  • It should be the same port unless one is HTTP and another is HTTPS. Could you try HTTP in your Asp.Net code?
    Friday, August 7, 2015 2:05 AM
  • I have [HTTPPost] as an attribute.  I am not sure how to do "HTTP in ASP.Net code".
    • Edited by RoshDsa Friday, August 7, 2015 2:34 PM
    Friday, August 7, 2015 1:51 PM
  • Please specify DefaultEndpointsProtocol=http;AccountName=myAccount;AccountKey=myKey; in your connection string.
    Friday, August 7, 2015 11:58 PM