I have an Azurite container running in Docker Desktop: enter image description here

I use .NET to implement upload, this is the code:

public async Task<Uri> UploadAsync(IFormFile file, CancellationToken cancellationToken = default)
{
    var fileName = $"{Guid.NewGuid()}{MimeTypeMap.GetExtension(file.ContentType)}";

    var container = new BlobContainerClient(_configuration.ConnectionString, _configuration.ContainerName);
    var blobClient = container.GetBlobClient(fileName);

    await blobClient.UploadAsync(file.OpenReadStream(), cancellationToken);

    return blobClient.Uri;
}

When I use "http://host.docker.internal:10000/devstoreaccount1" I can upload blobs (specifically images) without any issues. Generated URL looks like this:

"http://host.docker.internal:10000/devstoreaccount1/images/d2cb8b81-65d3-4b09-94b2-0907c01bf3ff.png"

But when I want to download (retrieve) image using that URL (and access token) I get "net::ERR_CONNECTION_TIMED_OUT" error. Although if I replace "host.docker.internal" with "127.0.0.1" I can download image without issues. But, if I try to upload using "127.0.0.1" address I get:

"Retry failed after 6 tries. Retry settings can be adjusted in ClientOptions.Retry. (Connection refused (127.0.0.1:10000))" error.

1

There are 1 answers

0
Mackovic On

I found two solutions for an issue I faced:

  • first one is to just simply save relative path in a database and use "host.docker.internal" for upload and "127.0.0.1" for download.
  • second one is to edit host file (usually located at "C:\Windows\System32\drivers\etc") and map 127.0.0.1 with host.docker.internal:enter image description here