How to fix "ModuleNotFoundError" for "azure.storage.blob" in Azure Container App

Hossein Miraftabi 0 Reputation points
2024-08-11T16:57:27.5733333+00:00

I have a Django microservice for which I've created a Dockerfile to build an image. Below is the Dockerfile:

FROM python:latest 
WORKDIR /app 
COPY . . 
RUN pip install --no-cache-dir -r requirements.txt 
EXPOSE 9999 
CMD ["python", "manage.py", "runserver", "0.0.0.0:9999"]

The requirements.txt file includes all the dependencies needed for the application. After pushing the image to Azure Container Registry (ACR), I created an Azure Container App that pulls the image and attempts to run it. However, the application fails to start with the following error:

from azure.storage.blob import BlobServiceClient 
ModuleNotFoundError: No module named 'azure'

I tested the image locally, and it runs without issues. I also checked inside the container, and all the dependencies listed in requirements.txt are present. I'm seeking assistance to understand why this error is occurring and how to resolve it.

Requirements.txt file is as follows:

amqp==5.2.0
annotated-types==0.7.0
anyio==4.4.0
asgiref==3.8.1
azure-core==1.30.2
azure-identity==1.17.1
azure-storage-blob==12.22.0
billiard==4.2.0
boto3==1.34.157
botocore==1.34.157
celery==5.4.0
certifi==2024.7.4
cffi==1.17.0
charset-normalizer==3.3.2
click==8.1.7
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.3.0
cryptography==43.0.0
distro==1.9.0
Django==5.1
django-storages==1.14.3
djangorestframework==3.15.2
fire==0.6.0
flower==2.0.1
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
humanize==4.10.0
idna==3.7
isodate==0.6.1
jiter==0.5.0
jmespath==1.0.1
kombu==5.3.7
markdown-it-py==3.0.0
mdurl==0.1.2
msal==1.30.0
msal-extensions==1.2.0
openai==1.40.1
orjson==3.10.6
pillow==10.3.0
portalocker==2.10.1
prometheus_client==0.20.0
prompt_toolkit==3.0.47
pycparser==2.22
pydantic==2.8.2
pydantic_core==2.20.1
Pygments==2.18.0
PyJWT==2.9.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.1
redis==5.0.7
requests==2.32.3
rich==13.7.1
s3transfer==0.10.2
simpleaichat==0.2.2
six==1.16.0
sniffio==1.3.1
sqlparse==0.5.1
termcolor==2.4.0
tornado==6.4.1
tqdm==4.66.5
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
vine==5.1.0
wcwidth==0.2.13

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
431 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Manu Philip 18,566 Reputation points MVP
    2024-08-13T04:27:35.91+00:00

    Hi,

    I guess, you are missing some of the required packages like the following in the requirement.txt file. You may try adding the following packages and try again. If this is also not helps, we need to find the other similar missing packages

    azure-mgmt-resource

    azure-mgmt-storage

    azure-identity

    Hope this helps.


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.