Azure
Azure Container Apps: Serverless Container Platform Guide
Master Azure Container Apps with this comprehensive guide covering serverless containers, deployment patterns, and best practices
March 15, 2024
DevHub Team
4 min read
Azure Container Apps: Serverless Container Platform Guide
Azure Container Apps is a fully managed serverless container service that enables you to run microservices and containerized applications on a serverless platform. This guide explores its features, deployment patterns, and best practices.
Service Overview
graph TB
subgraph "Azure Container Apps Environment"
direction TB
E["Environment"]
subgraph "Container Apps"
A["App 1"]
B["App 2"]
C["App N"]
end
subgraph "Features"
D["Auto-scaling"]
F["HTTPS Ingress"]
G["Service Discovery"]
end
end
A --> D
B --> F
C --> G
classDef azure fill:#0078D4,stroke:#fff,color:#fff
class E,A,B,C,D,F,G azure
Key Features
Feature | Description | Benefits |
---|---|---|
Serverless Containers | Run containers without managing infrastructure | Reduced operational overhead |
Auto-scaling | Scale based on HTTP traffic, events, or metrics | Cost optimization and performance |
Microservices | Built-in service discovery and ingress | Simplified architecture |
DAPR Integration | Distributed application runtime support | Enhanced microservices capabilities |
Deployment Patterns
Basic Deployment
import { ContainerApp, ContainerAppEnvironment } from '@azure/arm-appcontainers'; const containerApp = { location: 'eastus', managedEnvironmentId: environment.id, configuration: { ingress: { external: true, targetPort: 80 } }, template: { containers: [ { name: 'myapp', image: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest', resources: { cpu: 0.5, memory: '1Gi' } } ], scale: { minReplicas: 1, maxReplicas: 10 } } };
Advanced Configuration
# container-app.yaml properties: managedEnvironmentId: /subscriptions/.../environments/myenv configuration: activeRevisionsMode: Multiple secrets: - name: redis-password value: mypassword ingress: external: true targetPort: 80 transport: http allowInsecure: false template: containers: - name: myapp image: myregistry.azurecr.io/myapp:latest env: - name: REDIS_HOST value: redis.internal - name: REDIS_PASSWORD secretRef: redis-password scale: minReplicas: 1 maxReplicas: 10 rules: - name: http-rule http: metadata: concurrentRequests: "100"
Scaling Strategies
HTTP Scaling
Metric | Description | Example Value |
---|---|---|
Concurrent Requests | Number of simultaneous requests | 100 |
Response Time | Average response latency | 500ms |
Request Rate | Requests per second | 50 |
Event-driven Scaling
const eventDrivenScale = { scale: { minReplicas: 0, maxReplicas: 10, rules: [ { name: "azure-queue", azureQueue: { queueName: "myqueue", queueLength: 100 } } ] } };
Networking and Security
Network Integration
graph TB
subgraph "Virtual Network"
direction TB
ACA["Container Apps"]
PE["Private Endpoints"]
SN["Subnet"]
end
subgraph "External Services"
DB["Azure Database"]
CR["Container Registry"]
KV["Key Vault"]
end
ACA --> PE
PE --> DB
PE --> CR
PE --> KV
classDef azure fill:#0078D4,stroke:#fff,color:#fff
class ACA,PE,SN,DB,CR,KV azure
Security Configuration
# security-config.yaml properties: configuration: secrets: - name: ssl-cert value: base64-encoded-cert ingress: external: true targetPort: 443 transport: http2 allowInsecure: false customDomains: - name: app.example.com certificateRef: ssl-cert dapr: enabled: true appPort: 3000 appProtocol: http
Monitoring and Logging
Application Insights Integration
const monitoringConfig = { configuration: { monitoring: { enabled: true, appInsightsInstrumentationKey: process.env.APPINSIGHTS_KEY } } };
Log Analytics
Log Type | Description | Retention |
---|---|---|
Container Logs | Application stdout/stderr | 30 days |
System Logs | Platform-level events | 90 days |
Audit Logs | Security and access events | 365 days |
Best Practices
Performance Optimization
-
Container Image Optimization
- Use multi-stage builds
- Minimize image size
- Implement layer caching
- Use production-ready base images
-
Resource Management
- Set appropriate resource limits
- Configure auto-scaling thresholds
- Monitor resource usage
- Implement graceful shutdown
High Availability
-
Multi-region Deployment
const regions = ['eastus', 'westus']; for (const region of regions) { const containerApp = { location: region, // ... configuration }; // Deploy to each region }
-
Traffic Management
# traffic-split.yaml properties: configuration: ingress: traffic: - revisionName: myapp-v1 weight: 90 - revisionName: myapp-v2 weight: 10
Troubleshooting Guide
Common Issues
Issue | Possible Cause | Solution |
---|---|---|
Container Crash | Resource limits | Adjust memory/CPU limits |
Scaling Issues | Incorrect rules | Verify scaling configuration |
Network Errors | Misconfigured ingress | Check network settings |
References
- Azure Container Apps Documentation
- Container Apps Pricing
- DAPR Documentation
- Azure Monitor Documentation
- Networking Best Practices
- Security Guidelines
Related Posts
- Azure OpenAI Service - Integrate AI capabilities with Container Apps
- Azure Kubernetes Service Cost - Compare container hosting options
- Azure DevOps Pipeline - Set up CI/CD for Container Apps
- Azure Functions v4 - Serverless alternatives to Container Apps
Container Apps
Serverless
Microservices
DevOps