title: Connect to Azurite from .NET App via Docker
body: <p>I have a .NET 6 API (running in Docker), and Azurite (running in Docker).</p>
  <p>I'm trying to connect to Azurite from the .NET app using the .NET SDK, but am getting the following error in the Docker logs:</p>
  <blockquote>
  <p>System.AggregateException: Retry failed after 6 tries. Retry settings
  can be adjusted in ClientOptions.Retry. (Connection refused
  (azurite:10000)) (Connection refused (azurite:10000)) (Connection
  refused (azurite:10000)) (Connection refused (azurite:10000))
  (Connection refused (azurite:10000)) (Connection refused
  (azurite:10000))</p>
  </blockquote>
  <p>It's dying on this second line (<code>CreateIfNotExists()</code>):</p>
  <pre><code>_blobContainerClient = new BlobContainerClient(connectionString, containerName);
  _blobContainerClient.CreateIfNotExists();
  </code></pre>
  <p>Here's my connection string in my .NET app:</p>
  <pre><code>&quot;Azure&quot;: {
          &quot;StorageConnectionString&quot;: &quot;UseDevelopmentStorage=true&quot;
      }
  </code></pre>
  <p>Here is my <code>docker-compose.yml</code> file:</p>
  <pre><code>version: '3.4'
  
  services:
    api:
      image: ${DOCKER_REGISTRY-}api
      container_name: aft-backend-api
      build:
        context: src
        dockerfile: API/Dockerfile    
      networks:
        - aft-backend
      environment:
        - ASPNETCORE_URLS=http://+:5000
        - Azure__StorageConnectionString=UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://azurite;
      depends_on:
        - azurite
    azurite:
      image: mcr.microsoft.com/azure-storage/azurite
      container_name: aft-backend-azurite
      hostname: azurite
      restart: always
      command: 'azurite --blobHost 127.0.0.1 --blobPort 10000 --queueHost 127.0.0.1 --queuePort 10001'
      ports:
        - 10000:10000
        - 10001:10001
      networks:
        - aft-backend
  
  networks:
    aft-backend:
      name: aft-backend-network
  </code></pre>
  <p>Things to note:</p>
  <ul>
  <li>I'm overriding the connection string in the compose file, by using the <code>environment</code> variable</li>
  <li>I've set the <code>DevelopmentStorageProxyUri</code> to the hostname (azurite)</li>
  <li>I'm using <code>depends_on</code> to ensure that Azurite starts up before the API</li>
  </ul>
  <p>I noticed this <a href="https://stackoverflow.com/questions/59615330/connecting-to-azurite-using-a-hostname-fails">similar question</a>, however it seems outdated and doesn't' have a clear answer.</p>
  <p>Can anyone help?</p>
  <p>Thanks in advance.</p>