I have a .NET 6 API (running in Docker), and Azurite (running in Docker).
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:
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))
It's dying on this second line (CreateIfNotExists()
):
_blobContainerClient = new BlobContainerClient(connectionString, containerName);
_blobContainerClient.CreateIfNotExists();
Here's my connection string in my .NET app:
"Azure": {
"StorageConnectionString": "UseDevelopmentStorage=true"
}
Here is my docker-compose.yml
file:
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
Things to note:
- I'm overriding the connection string in the compose file, by using the
environment
variable - I've set the
DevelopmentStorageProxyUri
to the hostname (azurite) - I'm using
depends_on
to ensure that Azurite starts up before the API
I noticed this similar question, however it seems outdated and doesn't' have a clear answer.
Can anyone help?
Thanks in advance.