> ## Documentation Index
> Fetch the complete documentation index at: https://shivamgoyal.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Production Deployment

> Deploy CodeNull AI Backend to production using Azure Container Registry

# 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

<Steps>
  <Step title="Create an Azure Container Registry">
    ```bash theme={null}
    az acr create \
      --resource-group web-fastapi-codenull-rg \
      --name codenullregistry \
      --sku Basic
    ```

    This creates a Basic tier Azure Container Registry named `codenullregistry`.
  </Step>

  <Step title="Login to your Azure Container Registry">
    ```bash theme={null}
    az acr login --name codenullregistry
    ```

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

    Alternatively, use Docker login command:

    ```bash theme={null}
    docker login <your-registry>.azurecr.io -u <username> -p <password>
    ```

    Replace the placeholders with your actual container registry information.
  </Step>
</Steps>

## Building and Pushing Your Docker Image

<Steps>
  <Step title="Build your Docker image">
    ```bash theme={null}
    docker build -t codenull-ai-backend .
    ```
  </Step>

  <Step title="Tag the image for your registry">
    ```bash theme={null}
    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.
  </Step>

  <Step title="Push the image to ACR">
    ```bash theme={null}
    docker push <your-registry>.azurecr.io/codenull-ai-backend:latest
    ```

    This uploads your Docker image to Azure Container Registry.
  </Step>
</Steps>

## Deploying from Azure Container Registry

```bash theme={null}
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:

```bash theme={null}
az containerapp show -n web-codenull-app -g web-fastapi-codenull-rg
```

To stream logs from your container app:

```bash theme={null}
az containerapp logs show -n web-codenull-app -g web-fastapi-codenull-rg
```

## Next Steps

* [Configure monitoring for your application](/deployment/monitoring)
* Implement autoscaling based on traffic patterns
* Set up regular database backups
