Hands-on Challenge Day - Deploying with Docker on Azure App Service
In the modern era of software development, containerization has become a key strategy for deploying applications quickly, reliably, and consistently across various environments. Docker, a leading containerization platform, packages applications and their dependencies into containers, ensuring that they work seamlessly in any environment. Microsoft Azure App Service provides a fully managed platform for building, deploying, and scaling web apps, offering seamless integration with Docker containers.
Deploying Docker containers on Azure App Service simplifies the process of managing and scaling web applications. It combines the benefits of containerization—such as isolation, quick deployment, and scalability—with the powerful features of Azure App Service, including automated deployments, auto-scaling, and integration with Azure DevOps.
"QuickDeliver Inc.", a startup specializing in delivery tracking software, has developed a web application to improve logistics operations. Their application has grown in popularity, and they need to scale their deployment quickly while maintaining high availability. They've decided to leverage Docker for containerization and Azure App Service for cloud deployment to meet their needs.
Problem Statement: QuickDeliver Inc. faces challenges with deploying updates and scaling their application efficiently to handle increased load.
Your Mission: Deploy QuickDeliver Inc.'s web application as a Docker container on Azure App Service, ensuring the solution is scalable, resilient, and easy to update.
Prepare the Web Application:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'Welcome to QuickDeliver Tracking Software!'
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=80)
# Use an official Python runtime as a parent image
FROM python:3.8-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir Flask
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME QuickDeliver
# Run app.py when the container launches
CMD ["python", "app.py"]
Build and Push the Docker Image:
docker build -t quickdeliverapp .
docker tag quickdeliverapp <your_registry>/quickdeliverapp:latest
docker push <your_registry>/quickdeliverapp:latest
Create Azure App Service Plan and Web App:
az group create --name QuickDeliverResourceGroup --location eastus
az appservice plan create --name QuickDeliverAppServicePlan --resource-group QuickDeliverResourceGroup --is-linux --sku B1
az webapp create --resource-group QuickDeliverResourceGroup --plan QuickDeliverAppServicePlan --name <unique_app_name> --deployment-container-image-name <your_registry>/quickdeliverapp:latest