TL;DR
A comprehensive guide to Azure Container Apps, including deployment strategies, scaling, networking, and best practices for running containerized applications
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.
$1
`` 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
mermaid
`
$1
| 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 |
$1
$1
` 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
}
}
};
typescript
`
$1
` 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"
yaml
`container-app.yaml
$1
$1
| Metric | Description | Example Value |
|---|---|---|
| Concurrent Requests | Number of simultaneous requests | 100 |
| Response Time | Average response latency | 500ms |
| Request Rate | Requests per second | 50 |
$1
` const eventDrivenScale = {
scale: {
minReplicas: 0,
maxReplicas: 10,
rules: [
{
name: "azure-queue",
azureQueue: {
queueName: "myqueue",
queueLength: 100
}
}
]
}
};
typescript
`
$1
$1
` 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
mermaid
`
$1
` 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
yaml
`security-config.yaml
$1
$1
` const monitoringConfig = {
configuration: {
monitoring: {
enabled: true,
appInsightsInstrumentationKey: process.env.APPINSIGHTS_KEY
}
}
};
typescript
`
$1
| 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 |
$1
$1
1. Container Image Optimization
- Use multi-stage builds
- Minimize image size
- Implement layer caching
- Use production-ready base images
2. Resource Management
- Set appropriate resource limits
- Configure auto-scaling thresholds
- Monitor resource usage
- Implement graceful shutdown
$1
1. Multi-region Deployment
` const regions = ['eastus', 'westus'];
for (const region of regions) {
const containerApp = {
location: region,
// ... configuration
};
// Deploy to each region
}
typescript
`
2. Traffic Management
` # traffic-split.yaml
properties:
configuration:
ingress:
traffic:
- revisionName: myapp-v1
weight: 90
- revisionName: myapp-v2
weight: 10
yaml
``
$1
$1
| 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 |
$1
1. [Azure Container Apps Documentation](https://docs.microsoft.com/azure/container-apps)
2. [Container Apps Pricing](https://azure.microsoft.com/pricing/details/container-apps)
3. [DAPR Documentation](https://dapr.io)
4. [Azure Monitor Documentation](https://docs.microsoft.com/azure/azure-monitor)
5. [Networking Best Practices](https://docs.microsoft.com/azure/container-apps/networking)
6. [Security Guidelines](https://docs.microsoft.com/azure/container-apps/security)
$1
Why This Matters
Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.
Trade-offs to Consider
Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.
When NOT to Use This
Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.
Decision Framework
Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.