Production Deployment with Azure Container Registry

For production deployments, it’s recommended to use Azure Container Registry (ACR) to store and manage your Docker images. This approach provides better security, versioning, and integration with Azure services.

Setting Up Azure Container Registry

1

Create an Azure Container Registry

az acr create \
  --resource-group web-fastapi-codenull-rg \
  --name codenullregistry \
  --sku Basic

This creates a Basic tier Azure Container Registry named codenullregistry.

2

Login to your Azure Container Registry

az acr login --name codenullregistry

This authenticates your local Docker client with your Azure Container Registry.

Alternatively, use Docker login command:

docker login <your-registry>.azurecr.io -u <username> -p <password>

Replace the placeholders with your actual container registry information.

Building and Pushing Your Docker Image

1

Build your Docker image

docker build -t codenull-ai-backend .
2

Tag the image for your registry

docker tag codenull-ai-backend <your-registry>.azurecr.io/codenull-ai-backend:latest

This tags your local image with your Azure Container Registry’s address.

3

Push the image to ACR

docker push <your-registry>.azurecr.io/codenull-ai-backend:latest

This uploads your Docker image to Azure Container Registry.

Deploying from Azure Container Registry

az containerapp create \
    --resource-group web-fastapi-codenull-rg \
    --name web-codenull-app \
    --image <your-registry>.azurecr.io/codenull-ai-backend:latest \
    --registry-server <your-registry>.azurecr.io \
    --registry-username <username> \
    --registry-password <password> \
    --ingress external \
    --target-port 8000

Accessing Your Deployed Application

After deployment, your application will be accessible at:

https://<your-app-name>.<region>.azurecontainerapps.io/

API Documentation

The API documentation is available at:

https://<your-app-name>.<region>.azurecontainerapps.io/docs

Monitoring and Logs

To view deployment information:

az containerapp show -n web-codenull-app -g web-fastapi-codenull-rg

To stream logs from your container app:

az containerapp logs show -n web-codenull-app -g web-fastapi-codenull-rg

Next Steps