Overview of Python Container Apps in Azure - Python on Azure | Microsoft Learn
Read in English Edit Note Access to this page requires authorization. You can try signing in or changing directories . Access to this page requires authorization. You can try changing directories . Overview of Python Container Apps in Azure This article explains how to take a Python project—such as a web application—and deploy it as a Docker container in Azure. It covers the general containerization workflow, Azure deployment options for containers, and Python-specific container configurations within Azure.
Building and deploying Docker containers in Azure follows a standard process across languages, with Python-specific configurations in the Dockerfile, requirements.txt, and settings for web frameworks like Django , Flask , and FastAPI . Container workflow scenarios For Python container development, the following table describes some typical workflows for moving from code to container. Scenario Description Workflow Dev Build Python Docker images locally in your development environment.
Code : Clone your app code locally by using Git (with Docker installed). Build : Use Docker CLI, VS Code (with extensions), PyCharm (with Docker plugin). Described in section Working with Python Docker images and containers . Test : Run and test the container locally. Push : Push the image to a container registry like Azure Container Registry, Docker Hub, or private registry. Deploy : Deploy the container from the registry to an Azure service.
Hybrid Build Docker images in Azure, but initiate the process from your local environment. Code : Clone the code locally (not necessary for Docker to be installed). Build : To trigger builds in Azure, use VS Code (with remote extensions) or the Azure CLI. Push : Push the built image to Azure Container Registry. Deploy : Deploy the container from the registry to an Azure service. Azure Use Azure Cloud Shell to build and deploy containers entirely in the cloud.
Code : Clone the GitHub repo in Azure Cloud Shell. Build : Use Azure CLI or Docker CLI in Cloud Shell. Push : Push the image to a registry like Azure Container Registry, Docker Hub, or private registry. Deploy : Deploy the container from the registry to an Azure service. The end goal of these workflows is to have a container running in one of the Azure resources that support Docker containers as listed in the next section.
A dev environment can be: Your local workstation with Visual Studio Code or PyCharm Codespaces (a development environment hosted in the cloud) Visual Studio Dev Containers (a container as a development environment) Deployment container options in Azure Python container apps are supported in the following services. Service Description Web App for Containers Azure App Service is a fully managed hosting platform for containerized web applications, including websites and web APIs.
It supports scalable deployments and integrates seamlessly with CI/CD workflows using Docker Hub, Azure Container Registry, and GitHub. This service is ideal for developers who want a simple and efficient path to deploy containerized apps, while also benefiting from the full capabilities of the Azure App Service platform. By packaging your application and all its dependencies into a single deployable container, you gain both portability and ease of management—without needing to manage infrastructure.
Example: Deploy a Flask or FastAPI web app on Azure App Service . Azure Container Apps (ACA) Azure Container Apps (ACA) is a fully managed serverless container service powered by Kubernetes and open-source technologies like Dapr , KEDA , and envoy . Its design incorporates industry best practices and is optimized for executing general-purpose containers. ACA abstracts away the complexity of managing a Kubernetes infrastructure—direct access to the Kubernetes API isn't required or supported.
Instead, it offers higher-level application constructs such as revisions, scaling, certificates, and environments to simplify development and deployment workflows. This service is ideal for development teams looking to build and deploy containerized microservices with minimal operational overhead, allowing them to focus on application logic instead of infrastructure management. Example: Deploy a Flask or FastAPI web app on Azure Container Apps .
Azure Container Instances (ACI) Azure Container Instances (ACI) is a serverless offering that provides a single pod of Hyper-V isolated containers on demand. Billing is based on actual resource consumption rather than pre-allocated infrastructure, making it well-suited for short-lived or burstable workloads. Unlike other container services, ACI doesn't include built-in support for concepts like scaling, load balancing, or TLS certificates.
Instead, it typically functions as a foundational container building block, often integrated with Azure services like Azure Kubernetes Service (AKS) for orchestration. ACI excels as a lightweight choice when the higher-level abstractions and features of Azure Container Apps aren't needed Example: Create a container image for deployment to Azure Container Instances . (The tutorial isn't Python-specific, but the concepts shown apply to all languages.) Azure Kubernetes Service (AKS) Azure Kubernetes Service (AKS) is a fully managed Kubernetes option in Azure that gives you complete control over your Kubernetes environment.
It supports direct access to the Kubernetes API and can run any standard Kubernetes workload. The full cluster resides in your subscription, with the cluster configurations and operations within your control and responsibility. AKS is ideal for teams needing fine-grained control over scaling, networking, and deployment of containerized applications. Azure handles the control plane and infrastructure provisioning, but the day-to-day operation and security of the cluster are within your team's control.
This service is ideal for teams that want the flexibility and power of Kubernetes with the added benefit of Azure's managed infrastructure, while still maintaining full ownership over the cluster environment. Example: Deploy an Azure Kubernetes Service cluster using the Azure CLI . Azure Functions Azure Functions offers an event-driven, serverless Functions-as-a-Service (FaaS) platform that lets you run small pieces of code (functions) in response to events—without managing infrastructure.
Azure Functions shares many characteristics with Azure Container Apps around scale and integration with events, but is optimized for short-lived functions deployed as either code or containers. Ideal for teams looking to trigger the execution of functions on events; for example, to bind to other data sources. Like Azure Container Apps, Azure Functions supports automatic scaling and integration with event sources (for example, HTTP requests, message queues, or blob storage updates).
This service is ideal for teams building lightweight, event-triggered workflows, such as processing file uploads or responding to database changes, in Python or other languages. Example: Create a function on Linux using a custom container . For a more detailed comparison of these services, see Comparing Container Apps with other Azure container options . Virtual environments and containers Virtual environments in Python isolate project dependencies from system-level Python installations, ensuring consistency across development environments.
A virtual environment includes its own isolated Python interpreter, along with the libraries and scripts needed to run the specific project code within that environment. You manage dependencies for Python projects through the requirements.txt file. By specifying dependencies in a requirements.txt file, you can reproduce the exact environment needed for your project. This approach facilitates smoother transitions to containerized deployments like Azure App Service, where environment consistency is essential for reliable application performance.
Tip In containerized Python projects, you typically don't
The rest of this page is on the live site.