Container Deployment and Management
Azure App Service provides a robust platform for hosting containerized applications. You can deploy single containers or multi-container applications using Docker Compose.
This documentation guides you through deploying, configuring, and managing your containerized applications on App Service, leveraging the benefits of a fully managed platform.
To get started, you'll need an Azure subscription and Docker installed locally. The basic steps involve:
Tip: For seamless integration, consider using Azure Container Registry (ACR) for your Docker images.
Azure App Service supports several deployment methods for containers:
This is the simplest way to deploy a containerized web app. You point App Service to your Docker image in a registry.
Create an App Service plan and then the web app:
# Create a resource group
az group create --name myResourceGroup --location eastus
# Create an App Service plan for Linux
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku B1 --is-linux
# Create a web app with a Docker container
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name mycontainerapp --role Contributor --docker-custom-image-name myregistry.azurecr.io/myapp:v1 --docker-registry-server-url https://index.docker.io/v1/ --docker-registry-server-user --docker-registry-server-password
Replace placeholders with your specific registry details.
For applications composed of multiple services (e.g., web app, database, cache), you can use Docker Compose.
docker-compose.yml file that defines your services and their configurations.docker-compose.yml file (e.g., from a GitHub repository).Example docker-compose.yml:
version: '3.4'
services:
webfrontend:
image: myregistry.azurecr.io/webapp:latest
ports:
- "80:80"
environment:
- ASPNETCORE_URLS=http://+:80
backendapi:
image: myregistry.azurecr.io/api:latest
ports:
- "5000:80"
Note: For multi-container deployments, App Service for Containers uses a specific infrastructure that might differ slightly from a standard single-container setup. Ensure your ports are correctly exposed.
Once deployed, you can manage your containerized applications through the Azure Portal, Azure CLI, or Azure PowerShell.
Key configuration options include:
Access logs directly from the Azure Portal or configure diagnostic settings to send logs to Azure Monitor, Log Analytics, or other destinations.
You can scale your App Service plan or, for certain configurations, your container instances individually. Auto-scaling rules can be set based on CPU usage, memory, or HTTP queue length.
# Scale an App Service plan
az appservice plan update --name myAppServicePlan --resource-group myResourceGroup --set capacity=3
Use deployment slots for staging and production environments to test new versions of your container image with zero downtime.