Skip to main content

Overview

The Azure Container Apps provider runs code in fully managed serverless containers on Microsoft Azure. It provides automatic scaling, built-in security, and integration with Azure services.

Requirements

  • Azure subscription with Container Apps enabled
  • Service principal or managed identity with appropriate permissions
  • azure-mgmt-appcontainers package installed

Installation

# Install Azure dependencies
poetry install --extras cloud

# Or install directly
pip install azure-mgmt-appcontainers azure-identity

Configuration

Environment Variables

# Azure Credentials
AZURE_TENANT_ID=your-tenant-id
AZURE_CLIENT_ID=your-client-id
AZURE_CLIENT_SECRET=your-client-secret
AZURE_SUBSCRIPTION_ID=your-subscription-id

# Container Apps Settings
AZURE_RESOURCE_GROUP=nadoo-sandbox-rg
AZURE_CONTAINER_APP_ENV=nadoo-sandbox-env
AZURE_REGION=eastus
AZURE_CONTAINER_MEMORY=0.5Gi
AZURE_CONTAINER_CPU=0.25

Required Azure Roles

Assign to service principal:
  • Contributor on resource group
  • Container Apps Contributor

Usage

Execute on Azure Container Apps

curl -X POST http://localhost:8002/api/v1/execute \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "Console.WriteLine(\"Hello from Azure!\");",
    "language": "csharp",
    "provider": "azure_container"
  }'

Supported Languages

LanguageContainer Image
Pythonmcr.microsoft.com/azure-functions/python:4
JavaScriptmcr.microsoft.com/azure-functions/node:18
C#mcr.microsoft.com/dotnet/runtime:7.0
Javamcr.microsoft.com/java/jdk:17-distroless

Architecture

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Sandbox API    │────▶│  Container Apps │────▶│   Container     │
└─────────────────┘     │   Environment   │     │   Revision      │
                        └─────────────────┘     └─────────────────┘

Scaling Configuration

Automatic Scaling

Configure scale rules:
AZURE_CONTAINER_MIN_REPLICAS=0
AZURE_CONTAINER_MAX_REPLICAS=10

Scale Triggers

Azure Container Apps supports:
  • HTTP request-based scaling
  • CPU/Memory utilization
  • Custom metrics via KEDA

Cost Optimization

Container Apps charges based on:
  • vCPU seconds
  • Memory GiB seconds
  • HTTP requests (optional)
Tips:
  • Scale to zero when idle
  • Use consumption plan for variable workloads
  • Right-size CPU and memory allocations

Failover Configuration

Set up Azure as a failover provider:
EXECUTOR_DEFAULT_PROVIDER=local_docker
EXECUTOR_FALLBACK_CHAIN=local_docker,aws_lambda,azure_container

Security Features

Azure Container Apps provides:
  • Managed identity support
  • VNet integration
  • Private endpoints
  • Secrets management via Azure Key Vault
  • Built-in authentication

Monitoring

Integrate with Azure Monitor:
AZURE_LOG_ANALYTICS_WORKSPACE_ID=your-workspace-id
AZURE_LOG_ANALYTICS_SHARED_KEY=your-shared-key
View logs and metrics in Azure Portal or query via Log Analytics.