0

I am receiving an error when trying to get a container reference using the Azure storage API.

I can connect to my Azure storage account from the server explorer in Visual Studio. I can also connect from a test C# client I wrote, using the following code:

StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey("ACCOUNT", "XXXX")
CloudStorageAccount account = new CloudStorageAccount(credentials, true);
CloudBlobClient blobClient = account.CreateCloudBlobClient();

CloudBlobContainer container = blobClient.GetContainerReference(name);
container.CreateIfNotExist();

I created an ASP.NET MVC (Web API) application, and hosted it using IIS Express. I put the same code as above in a web method, and when I call this method from a client it does not work. It gets to the last line CreateIfNotExist(), waits a few minutes, and throws a System.Net.WebException error saying "Unable to connect to the remote server" ... "No connection could be made because the target machine actively refused it 168.63.33.206:443".

I find it strange that I can connect through other methods but not when I use local web application. Can anyone help? I've crawled the internet but can't find anyone with the same problem or with a decent solution.

Many thanks.

oranjutanj
  • 71
  • 2
  • 5
  • Welcome to Stack Overflow. I may be wrong here, but it seems that the actual problem here is not your code, but some configuration error. Please go through the docs. – bluefog Mar 18 '15 at 14:38
  • No it's not the code, that's the problem. I just wondered if anyone had any suggestions as to what the problem may be - e.g. network firewall (unlikely as it's working through server explorer) proxy (again unlikely for same reason), some Azure configuration that I'm unaware of, authentication mechanism etc. etc. – oranjutanj Mar 18 '15 at 14:52
  • 1
    Did you turn on Client-side Logging with the .NET Storage Client Library, that probably can give you more details on what's happening https://msdn.microsoft.com/en-us/library/azure/dn782839.aspx – Jason Tang - MSFT Mar 19 '15 at 00:44
  • Did you find any solution to this? I am also getting the same issue. :-( – Kushan Randima Jun 08 '18 at 04:51

1 Answers1

0

I'm not too familiar with IIS Express but, from what I've found...

"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different port. Once you start the process hosting your service try netstat -anb (requires admin privileges) to verify that it is running and listening on the expected port.

From this post: No connection could be made because the target machine actively refused it 127.0.0.1:3446

Also,

IIS Express is by default limited to only responding to requests from the localhost.

From this blog: http://blogs.blackmarble.co.uk/blogs/rfennell/post/2011/03/22/how-to-expose-iis-express-to-external-network-connections-and-use-a-non-self-signed-certificate.aspx

The SO post or the blog may help you solve your problem.

Community
  • 1
  • 1
Michael Curd
  • 617
  • 4
  • 10
  • Hi Michael thanks for the feedback, it does appear that it's some sort of network/firewall issue, as I have tried the same code from home and not through the corporate network and it works fine. Our IT guys won't look at it so I can't pin down the error. I shall plod on. Many thanks. – oranjutanj Mar 26 '15 at 08:39