download_blob does not work when dockerized (urllib3.connection.HTTPSConnection Errno -2)
See original GitHub issue- Package Name: azure.storage.blob
- Package Version: 12.4.0
- Operating System: Alpine Linux
- Python Version: 3.8
Describe the bug
Running the command download_stream = blobClient.download_blob()
does not work when the application is dockerized (works fine when debugging from VS Code).
The raised error is
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPSConnection object at 0x7f8c179660d0>: Failed to establish a new connection: [Errno -2] Name or service not known
Looking at the logs I spotted a difference between the 2 environments: the azure library is logging some info, and one of those is the request URL. When the application is dockerized, the url is (1), while (2) when debugging from VS Code (note that there is an extra " in (1))
- Request URL: ‘https://datalake.blob.core.windows.net"/giorgio/projectgiorgio/web_upload/natural_language_processing%20%281%29%20%281%29%20%281%29.pdf/4’
- Request URL: ‘https://datalake.blob.core.windows.net/giorgio/projectgiorgio/web_upload/natural_language_processing (1) (1) (1).pdf/4’
Here is the log produced during the error
To Reproduce Run the following Python code
import os
from azure.storage.blob import BlobServiceClient
container_name = "container_name"
blob_name = "blob_name"
blobServiceClient = BlobServiceClient.from_connection_string(os.getenv('STORAGE_CONNECTION_STRING'))
blobClient = blobServiceClient.get_blob_client(
container_name,
blob_name,
snapshot=None
)
download_stream = blobClient.download_blob() # <- error thrown here
content = download_stream.readall()
inside a docker container using the image tiangolo/uvicorn-gunicorn:python3.8
Expected behavior The file is downloaded correctly
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Failed to establish a new connection: [Errno -2] Name ... - GitHub
Hi, everyone: Docker failed when runing "RUN pip install flask", content of Docker file is as follows: FROM python:3.4 RUN mkdir /code COPY ......
Read more >Docker run connectionError - Stack Overflow
Here is my first attempt to use Docker image to implement Spring Boot ... to establish a new connection: [Errno -2] Name does...
Read more >Dockerizing Flask With Compose and Machine - Real Python
This article shows how to containerize Flask and Postgres for local Docker development as well as delivering the stack to the cloud via...
Read more >Connection refused? Docker networking and how it impacts ...
Learn how to fix connection refused errors when trying to connect to a Docker container.
Read more >Control startup and shutdown order in Compose
However, if you don't need this level of resilience, you can work around the problem with a wrapper script: Use a tool such...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am facing the exact same issue!
Update:
I was able to make it working after adding “connection_verify=False” parameter to the end of BlobServiceClient.from_connection_string() and blob_client.upload_blob() methods!