Azure App Service

Container Deployment and Management

Introduction to Container Support in Azure App Service

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.

Getting Started with Containerized Apps

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.

Key Features for Containers

Deployment Options

Azure App Service supports several deployment methods for containers:

1. Deploying a Single Container

This is the simplest way to deploy a containerized web app. You point App Service to your Docker image in a registry.

Using Azure CLI

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.

Using Azure Portal

  1. Navigate to the Azure Portal.
  2. Click "Create a resource".
  3. Search for "Web App" and select it.
  4. In the "Container" tab, choose "Docker Container".
  5. Select your desired registry, repository, and tag.
  6. Configure other settings like App Service Plan, OS (Linux recommended for containers), and region.
  7. Click "Review + create" and then "Create".

2. Deploying a Multi-Container App (Docker Compose)

For applications composed of multiple services (e.g., web app, database, cache), you can use Docker Compose.

  1. Create a docker-compose.yml file that defines your services and their configurations.
  2. Ensure your Docker Compose file is accessible, often by pushing it to a Git repository.
  3. When creating your App Service, select "Docker Compose" as the container configuration.
  4. Provide the path to your 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.

Managing Your Containerized Applications

Once deployed, you can manage your containerized applications through the Azure Portal, Azure CLI, or Azure PowerShell.

Configuration

Key configuration options include:

Monitoring and Logging

Access logs directly from the Azure Portal or configure diagnostic settings to send logs to Azure Monitor, Log Analytics, or other destinations.

Scaling

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
            

Deployment Slots

Use deployment slots for staging and production environments to test new versions of your container image with zero downtime.

Best Practices