| author | cephalin |
|---|---|
| ms.service | azure-app-service |
| ms.devlang | java |
| ms.custom | linux-related-content |
| ms.topic | quickstart |
| ms.date | 03/18/2025 |
| ms.author | cephalin |
In this quickstart, you learn how to deploy an image from Azure Container Registry to Azure App Service.
App Service on Linux provides predefined application stacks on Linux with support for languages like .NET, Java, Node.js, and PHP. You can also use a custom Docker image to run your web app on an application stack that isn't already defined in Azure.
For more information about containerized applications in a serverless environment, see Container apps.
- An Azure account.
- Docker.
- VS Code.
- The Azure App Service extension for VS Code. You can use this extension to create, manage, and deploy Linux web apps with Azure platform as a service (PaaS).
- The Docker extension for VS Code. You can use this extension to simplify the management of local Docker images and commands and to deploy built app images to Azure.
This quickstart uses Azure Container Registry as the registry. You can use other registries, but the steps might differ slightly.
Create a container registry by following the instructions in Quickstart: Create a private container registry by using the Azure portal.
Important
Be sure to set the Admin User option to Enable when you create the container registry. You can also set it from the Access keys section of your registry pane in the Azure portal. You need this setting to access App Service. For a managed identity, see Deploy from Azure Container Registry.
-
Open VS Code.
-
Select the Azure logo on the activity bar, and then go to ACCOUNTS & TENANTS. Select Sign in to Azure and follow the instructions.
:::image type="content" source="../../media/quickstart-docker/sign-in.png" alt-text="Screenshot that shows how to sign in to Azure in VS Code.":::
-
In the status bar at the bottom, verify that your Azure account email address is correct. Your subscription should be displayed in the APP SERVICE explorer.
-
In the activity bar, select the Docker logo. In the REGISTRIES explorer, verify that the container registry you created appears.
:::image type="content" source="../../media/quickstart-docker/registries.png" alt-text="Screenshot that shows the Registries value with Azure expanded.":::
Verify that Docker is installed and running. If Docker is running, the following command displays the Docker version:
docker --version-
In VS Code, open an empty folder and add a file called
Dockerfile. In the file, paste the content based on your desired language framework:In this file, the parent image is one of the built-in .NET containers of App Service.
FROM mcr.microsoft.com/appsvc/dotnetcore:lts ENV PORT 8080 EXPOSE 8080 ENV ASPNETCORE_URLS "http://*:${PORT}" ENTRYPOINT ["dotnet", "/defaulthome/hostingstart/hostingstart.dll"]
In this file, the parent image is one of the built-in Java containers of App Service. You can find the source files at java/tree/dev/java11-alpine. Its Dockerfile copies a simple Java app into
/tmp/appservice. Your Dockerfile starts that app.FROM mcr.microsoft.com/azure-app-service/java:11-java11_stable ENV PORT 80 EXPOSE 80 ENTRYPOINT ["java", "-Dserver.port=80", "-jar", "/tmp/appservice/parkingpage.jar"]
In this Dockerfile, the parent image is one of the built-in Node.js containers of App Service.
FROM mcr.microsoft.com/appsvc/node:10-lts ENV HOST 0.0.0.0 ENV PORT 8080 EXPOSE 8080 ENTRYPOINT ["pm2", "start", "--no-daemon", "/opt/startup/default-static-site.js"]
In this Dockerfile, the parent image is one of the built-in Python containers of App Service.
FROM mcr.microsoft.com/appsvc/python:latest ENV PORT 8080 EXPOSE 8080 ENTRYPOINT ["gunicorn", "--timeout", "600", "--access-logfile", "'-'", "--error-logfile", "'-'", "--chdir=/opt/defaultsite", "application:app"]
-
Open the command palette, and then type Docker Images: Build Image. Select Enter to run the command.
-
In the image tag box, specify the tag you want in the following format:
<acr-name>.azurecr.io/<image-name>:<tag>, where<acr-name>is the name of the container registry you created. Select Enter. -
When the image finishes building, select Refresh at the top of the IMAGES explorer and verify that the image built successfully.
:::image type="content" source="../../media/quickstart-docker/built-image.png" alt-text="Screenshot that shows the built image with tag.":::
-
In the activity bar, select the Docker icon. In the IMAGES explorer, find the image you built.
-
Expand the image, right-click on the tag you want, and select Push.
-
Make sure the image tag begins with
<acr-name>.azurecr.ioand select Enter. -
When VS Code finishes pushing the image to your container registry, select Refresh at the top of the REGISTRIES explorer and verify that the image was pushed successfully.
:::image type="content" source="../../media/quickstart-docker/image-in-registry.png" alt-text="Screenshot that shows the image deployed to Azure Container Registry.":::
- In the REGISTRIES explorer, expand the image, right-click the tag, and then select Deploy Image to Azure App Service.
- Follow the prompts to select a subscription, a globally unique app name, a resource group, and an App Service plan. Select B1 Basic for the pricing tier, and a region near you.
After deployment, your app is available at http://<app-name>.azurewebsites.net.
A resource group is a named collection of all your application's resources in Azure. For example, a resource group can contain a reference to a website, a database, and an Azure function.
An App Service plan defines the physical resources to use to host your website. This quickstart uses the Basic hosting plan on Linux infrastructure, which means the site is hosted on a Linux machine alongside other websites. If you start with the Basic plan, you can use the Azure portal to scale up so that a machine runs only your site. For pricing, see App Service pricing.
The Output panel shows the status of the deployment operations. When the operation finishes, select Open Site in the pop-up notification to open the site in your browser.
The App Service app pulls from the container registry every time it starts. If you rebuild your image, you just need to push it to your container registry, and the app pulls in the updated image when it restarts. To tell your app to pull in the updated image immediately, restart it.
To troubleshoot, go to I ran into an issue.
[!INCLUDE Clean-up Portal web app resources]
- Secure with a custom domain and certificate
- Migrate to a Windows container in Azure
- Integrate your app with an Azure virtual network
- Use private endpoints for App Service apps
- Azure Monitor overview
- Application monitoring for Azure App Service overview
- How to use managed identities for App Service and Azure Functions
- Configure custom container
- Sidecar container tutorial
Other Azure extensions:
- Azure Cosmos DB
- Azure Functions
- Azure CLI Tools
- Azure Resource Manager Tools
- Azure Tools extension pack includes all the extensions in this list.