Deploy a containerized Python web app on Azure with MongoDB - Python on Azure (original) (raw)

This tutorial series shows you how to containerize a Python web app and then either run it locally or deploy it to Azure App Service. App Service Web App for Containers allows you to focus on building your containers without worrying about managing and maintaining an underlying container orchestrator. When you are building web apps, Azure App Service is a good option for taking your first steps with containers. This container web app can use either a local MongoDB instance or MongoDB for Azure Cosmos DB to store data. For more information about using containers in Azure, see Comparing Azure container options.

In this tutorial you:

After completing the articles in this tutorial series, you'll have the basis for Continuous Integration (CI) and Continuous Deployment (CD) of a Python web app to Azure.

Service overview

The service diagram supporting this tutorial shows two environments: developer environment and Azure environment. It highlights the key Azure services used in the development process.

A screenshot of the services used in the Tutorial - Containerized Python App on Azure.

Developer environment

The components supporting the developer environment in this tutorial include:

Azure environment

The components supporting the Azure environment in this tutorial include:

Authentication

In this tutorial, you build a Docker image, either locally or in Azure, and then deploy it to Azure App Service. The App Service pulls the container image from an Azure Container Registry repository.

To securely pull images from the repository, App Service utilizes a system-assigned managed identity. This managed identity grants the web app permissions to interact with other Azure resources, eliminating the need for explicit credentials. For this tutorial, the managed identity is configured during setup of App Service to use a registry container image.

The tutorial sample web app uses MongoDB to store data. The sample code connects to Azure Cosmos DB via a connection string.

Prerequisites

To complete this tutorial, you need:

Sample app

The end result of this tutorial is a restaurant review app, deployed and running in Azure, that looks like the following screenshot.

A screenshot of the sample app created from the Python containerized web app used in the Tutorial - Containerized Python App on Azure.

In this tutorial, you build a Python restaurant review app that utilizes MongoDB for data storage. For an example app using PostgreSQL, see Create and deploy a Flask web app to Azure with a managed identity.

Next step