azure-storage-net: Cannot download blob data after upgrading to .net core 2.1 RTM (2.1.300)

CloudBlockBlob DownloadTextAsync (WindowsAzure.Storage 9.2.0) no longer connects and downloads the blob contents after upgrading to .NET Core 2.1

The same code works when running under using .NET Core 2.0 and .NET Core 2.1 RC1

Could this issue be linked to the changes that have been made to HttpClientHandler? Note: I am making the requests on a machine that is behind a ZScalar corporate firewall and proxy server.

I have Wireshark traces and can see that using 2.1 RTM it first does a DNS lookup and then tries to connect directly using TCP to XXX.store.core.windows.net on port 443, the request does not go through the proxy server and the connection is not established. Using a previous version on .NET Core it successfully connects using HTTP via the proxy server.

Here’s the code:

string storageConnectionString = "[SecretDetailsRemoved];EndpointSuffix=core.windows.net";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
string blobName = "myblob";
string container = "mycontainer";
Uri uri = new Uri($"{storageAccount.BlobEndpoint}{container}/{blobName}");
CloudBlockBlob blob = new CloudBlockBlob(uri, storageAccount.Credentials);
string content = await blob.DownloadTextAsync();

Here’s the exception:

Microsoft.WindowsAzure.Storage.StorageException: 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Thanks for the suggestion. All web requests fail.

For example, this code gives the same error:

   using (HttpClient client = new HttpClient())
   {
      string content = await client.GetStringAsync("http://www.microsoft.com");
   }

I am running in a windows environment and would expect the proxy settings to default to the IE settings.

As a workaround I have found that my code works if I opt out of using the new sockets implementation using the following command:

AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);

For information on this command see: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-2-1#api-changes and scroll to Sockets improvements

It is not ideal though to have to use the old implementation as the new library promises performance improvements!

It would be great if an IWebProxy implementation could be provided when creating the clients. The EventProcessorHost in https://github.com/Azure/azure-event-hubs-dotnet/ allows for this and it works nicely for the EventHubClient. Unfortunately, as I described in https://github.com/Azure/azure-event-hubs-dotnet/issues/210#issuecomment-418019549 they are unable to pass the IWebProxy further through to the creation of the CloudBlobClient. I would love to see consistent support for IWebProxy across the Azure libraries as clearly these are regularly used inside corporate environments and .NET Core adoption is only going to continue to grow.