I tried to deploy a instance of a simple FastAPI service into azure.
I have tried several ways, using uvicorn as server, using gunicorn with uvicorn workers, using an image from Docker Hub, uploading the image to Container Registry in Azure...
When I create the Docker image and run it at local it works perfectly, but then in Azure is not working.
This is my main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"msg": "Hola FastAPI!!"}
@app.get("/url")
async def url():
return {"url": "http://whatever.es"}
This is my Dockerfile
# syntax=docker/dockerfile:1
FROM python:3.11
WORKDIR /code
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["gunicorn" ,"--config", "gunicorn.py", "main:app"]
This is the gunicorn.py configuration file:
# Gunicorn configuration file
import multiprocessing
bind = "0.0.0.0:8000"
worker_class = "uvicorn.workers.UvicornWorker"
workers = multiprocessing.cpu_count() * 2 + 1
This is my requirements.txt
fastapi
uvicorn
gunicorn
As I told you, all the process seem to be ok until the last step, after the deployment, I got this message and the server is not listening in the port 8000. In local it works perfectly.
As you can see it says that is in a waiting state.
I appreciate your help.
I have tried to execute my container image in an Azure Container Instance.
I am expecting to have my service running in :8000
The result is that is nothing running there




docker run name-of-imageas usual. In ACI you don't need to run the Docker, it is executed by default and when you click the "play button"