Azure
Azure
Deploy to Microsoft Azure using App Service or Container Apps.
When to Use Azure
Best for:
- Microsoft/enterprise environments
- .NET ecosystem integration
- Hybrid cloud scenarios
- Compliance (government, healthcare)
Consider alternatives if:
- Not already using Microsoft tools
- Want simpler pricing model
Deployment Options
| Option | Best For | Complexity |
|---|---|---|
| Container Apps | Serverless containers | Low |
| App Service | Web apps with containers | Low |
| AKS | Kubernetes workloads | High |
Option 1: Container Apps (Recommended)
Modern serverless container platform.
Prerequisites
- Azure Account
- Azure CLI installed
- Docker image ready
Step 1: Configure Azure CLI
Step 2: Create Container Registry
bash# Create ACR az acr create \ --resource-group myapp-rg \ --name myappregistry \ --sku Basic # Login to ACR az acr login --name myappregistry # Build and push az acr build \ --registry myappregistry \ --image myapp:latest .
Step 3: Deploy Container App
bashaz containerapp create \ --name myapp \ --resource-group myapp-rg \ --environment myapp-env \ --image myappregistry.azurecr.io/myapp:latest \ --target-port 3000 \ --ingress external \ --registry-server myappregistry.azurecr.io \ --min-replicas 0 \ --max-replicas 10
Step 4: Verify
bash# Get the URL az containerapp show \ --name myapp \ --resource-group myapp-rg \ --query properties.configuration.ingress.fqdn # Test curl https://myapp.niceocean-xxxxx.eastus.azurecontainerapps.io/api/health
Option 2: App Service
Traditional PaaS web hosting.
Deploy from Container
bash# Create App Service plan az appservice plan create \ --name myapp-plan \ --resource-group myapp-rg \ --sku B1 \ --is-linux # Create Web App az webapp create \ --resource-group myapp-rg \ --plan myapp-plan \ --name myapp \ --deployment-container-image-name myappregistry.azurecr.io/myapp:latest # Configure container settings az webapp config container set \ --name myapp \ --resource-group myapp-rg \ --docker-custom-image-name myappregistry.azurecr.io/myapp:latest
Environment Variables
Setting Variables
bashaz containerapp update \ --name myapp \ --resource-group myapp-rg \ --set-env-vars "NODE_ENV=production" "API_URL=https://api.example.com"
Using Key Vault
bash# Create Key Vault az keyvault create \ --name myapp-kv \ --resource-group myapp-rg # Add secret az keyvault secret set \ --vault-name myapp-kv \ --name DATABASE-URL \ --value "postgresql://..." # Reference in Container Apps az containerapp update \ --name myapp \ --resource-group myapp-rg \ --set-env-vars "DATABASE_URL=secretref:database-url"
CI/CD with Azure DevOps
Create azure-pipelines.yml:
yamltrigger: - main pool: vmImage: ubuntu-latest steps: - task: Docker@2 inputs: containerRegistry: myappregistry repository: myapp command: buildAndPush Dockerfile: '**/Dockerfile' tags: | $(Build.BuildId) latest - task: AzureContainerApps@1 inputs: azureSubscription: 'Azure Subscription' containerAppName: myapp resourceGroup: myapp-rg imageToDeploy: myappregistry.azurecr.io/myapp:$(Build.BuildId)
Common Issues
| Issue | Solution |
|---|---|
| ACR access denied | Enable admin user or use managed identity |
| Container won't start | Check logs in Azure Portal |
| Slow cold starts | Use min-replicas > 0 |
| Port issues | Verify target-port matches Dockerfile EXPOSE |
Cost Considerations
| Service | Starting Price |
|---|---|
| Container Apps | Free tier: 180K vCPU-seconds/month |
| App Service B1 | ~$13/month |
| AKS | Cluster management free, pay for VMs |
Verify Deployment
- Container App is running
- External ingress is enabled
- Health endpoint responds
- Environment variables are set