| title | Tutorial: Containerized Python web apps on Azure: build image in Azure Container Registry |
|---|---|
| description | Build a containerized Python web app in the cloud. |
| ms.topic | conceptual |
| ms.date | 07/07/2022 |
| ms.custom | devx-track-python |
| ms.prod | azure-python |
| author | jess-johnson-msft |
| ms.author | jejohn |
This article is part of a tutorial about containerizing and deploy a Python web app to Azure App Service. App Service enables you to run containerized web apps and deploy through continuous integration/continuous deployment (CI/CD) capabilities with Docker Hub, Azure Container Registry, and Visual Studio Team Services. In this part of the tutorial, you learn how to build the containerized Python web app in the cloud.
In the previous part of this tutorial, a container image was build and run locally. In this part of the tutorial, you'll build (containerize) a Python web app into a Docker image in the cloud, specifically in Azure Container Registry. Building in the cloud has the advantage of being faster and easier when deploying existing code like the sample apps.
Before you can deploy a Docker image to App service, the image must be uploaded to a container registry. In this tutorial, you'll work with Azure Container Registry (ACR).
If you already have an Azure Container Registry, go to the next step. If you don't, create one.
Sign in to the Azure portal and follow these steps to create your Azure Container Registry.
| Instructions | Screenshot |
|---|---|
| [!INCLUDE Include showing how to find container registries in Azure portal] | :::image type="content" source="./media/tutorial-container-web-app/portal-search-container-registries-240px.png" lightbox="./media/tutorial-container-web-app/portal-search-container-registries.png" alt-text="A screenshot showing how to search for container registries in Azure portal." ::: |
| [!INCLUDE Include showing how to start create of registry in Azure portal] | :::image type="content" source="./media/tutorial-container-web-app/portal-create-new-registry-240px.png" lightbox="./media/tutorial-container-web-app/portal-create-new-registry.png" alt-text="A screenshot showing how to create a new registry in Azure portal." ::: |
| [!INCLUDE Include showing how to review and create registry in Azure portal] | :::image type="content" source="./media/tutorial-container-web-app/portal-create-registry-form-240px.png" lightbox="./media/tutorial-container-web-app/portal-create-registry-form.png" alt-text="A screenshot showing how to specify a new registry in Azure portal." ::: |
| [!INCLUDE Include showing how to get qualified name of registry in Azure portal] | :::image type="content" source="./media/tutorial-container-web-app/portal-create-registry-login-server-240px.png" lightbox="./media/tutorial-container-web-app/portal-create-registry-login-server.png" alt-text="A screenshot showing how to find the login server value a registry in Azure portal." ::: |
These steps require the Docker extension for VS Code.
| Instructions | Screenshot |
|---|---|
| [!INCLUDE Include showing how to open command palette in VS Code] | :::image type="content" source="./media/tutorial-container-web-app/visual-studio-code-registry-tasks-240px.png" lightbox="./media/tutorial-container-web-app/visual-studio-code-registry-tasks.png" alt-text="A screenshot showing how to search for show registries tasks in Visual Studio Code." ::: |
| [!INCLUDE Include showing how to start create of registry in VS Code] | :::image type="content" source="./media/tutorial-container-web-app/visual-studio-code-create-registry-240px.gif" lightbox="./media/tutorial-container-web-app/visual-studio-code-create-registry.gif" alt-text="An animated GIF showing how to create a registry in Visual Studio Code." ::: |
| [!INCLUDE Include showing how to review and create registry in VS Code] | :::image type="content" source="./media/tutorial-container-web-app/visual-studio-code-registry-get-properties-240px.png" lightbox="./media/tutorial-container-web-app/visual-studio-code-registry-get-properties.png" alt-text="A screenshot showing how to get the properties of a registry in Visual Studio Code." ::: |
[!INCLUDE Include showing how create registry with Azure CLI]
Building the image in the cloud is faster and easier, and doesn't require Docker to be running in your dev environment.
Step 1. In the Docker extension, go to REGISTRIES and make sure you are connected to Azure.
Step 2: Select F1 or CTRL+SHIFT+P to open the command palette.
-
Type "registries".
-
Select the task Azure Container Registry: Build Image in Azure...
Step 3: Fill out the information.
- Tag image as <registry-name>.azurecr.io, using the fully qualified name.
- Select the registry you just created, that is <registry-name>.
- Select image of base OS as Linux
Check the OUTPUT window for progress and information on the build.
Step 1. Log into registry if you haven't done so already. Use az acr login --name <registry-name>.
Step 2. Build with az acr build -t
- List container images | one image showing portal
- Expand the REPOSITORIES node of the Docker exensio and find Azure registory.
- Expand subnodes until you see the latest image.
- List container images with
az acr repository list --name <registry-name> --output table.