Deploying to Azure Container Apps

Azure Container Apps is a serverless container service that enables you to run microservices and containerized applications on a serverless platform. This guide covers the process of deploying the CodeNull AI Backend to Azure Container Apps.

Testing Locally with Docker

Before deploying to Azure, it’s recommended to test your application locally:

1

Build the Docker image

docker build --tag codenull-ai-backend .

This compiles your application into a Docker image.

2

Run the container locally

docker run -d --name codenull-ai-backend -p 8000:8000 codenull-ai-backend

This starts a container with your application accessible at http://localhost:8000.

Login to Azure

Before deploying to Azure, you need to authenticate:

az login

Creating Azure Resources

If you haven’t already created a resource group, create one with:

az group create --name web-fastapi-codenull-rg --location westus2

Deploying to Azure Container Apps

Azure Container Apps allows you to deploy directly from your local source code:

az containerapp up \
    --resource-group web-fastapi-codenull-rg \
    --name web-codenull-app \
    --ingress external \
    --target-port 8000 \
    --source .

This command:

  • Creates a new container app called web-codenull-app
  • Configures it with external ingress to allow public access
  • Maps it to port 8000 (the port your application listens on)
  • Builds and deploys the application from the current directory

Viewing Your Deployment

To view details about your deployed container app:

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

Your application should now be accessible at the URL provided in the output (e.g., https://<your-app-name>.<region>.azurecontainerapps.io/).

API Endpoints

All endpoints (except health check) use the base path /codenull/ai/api/v1/. Here are some of the available endpoints:

  1. Health Check: GET /health
  2. Chat Completion: POST /codenull/ai/api/v1/chat-completion
  3. Generate Website: POST /codenull/ai/api/v1/generate-website
  4. Optimize SEO: POST /codenull/ai/api/v1/optimize-seo
  5. Evaluate Website: POST /codenull/ai/api/v1/evaluate-website

For comprehensive documentation, visit the API Reference.

Next Steps

For production deployments, we recommend: