Overview:
Azure App Service on Linux provides pre-defined application stacks on Linux with support for languages such as .NET, PHP, Node.js and others. You can also use a custom Docker image to run your web app on an application stack that isn’t already defined in Azure.
This post shows you how to deploy an image from an Azure Container Registry (ACR) to App Service.
Below are the Azure services available for Containers.

Demo: Run a custom container in Azure App Service
Prerequisites
- An Azure account
- Docker
- Visual Studio Code
- The Azure App Service extension for VS Code. You can use this extension to create, manage, and deploy Linux Web Apps on the 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.
- Understanding Container concepts: Refer below Posts
- Rehost an on-premises application to Containers
- App Modernization using AKS (Azure Kubernetes Services)
Steps (Summary):
1 – Create a container registry
2 – Sign in, VSC and verify Docker Images
3 – Check prerequisites (docker version)
4 – Create and build image; to simply starts that app
5 – Deploy to container registry
6 – Deploy to App Service
| Step | Desc/Manual Steps in VSC |
| 1 – Create a container registry: Azure Container Registry is a private registry service for building, storing, and managing container images and related artifacts. Other Options are: DockerHub: Docker Hub Container Image Library | App Containerization | mycintainerregistryrk.azurecr.io |
| 2 – Sign in, VSC and verify Docker Images | Check the images in VSC |
| 3 – Check prerequisites; check the docker version etc. | docker –version |
| 4 – Create and build image; this Docker file is used to simply starts that app; | use (Docker Images: Build Image), <acr-name>.azurecr.io/<image-name>/<tag> |
| 5 – Deploy to container registry; | Select Docker Images and Push, select mycintainerregistryrk.azurecr.io/dockerfile/1.0:latest |
| 6 – Deploy to App Service; | In the REGISTRIES explorer, expand the image, right-click the tag, and select Deploy image to Azure App Service. |
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.
Step-by-step
1 – Create a container registry
| 1 – Create a container registry | mycintainerregistryrk.azurecr.io |
Create either from Azure Portal.
And validate in VSC.
Command/CLI
| Log in to registry | az acr login –name <registry-name> | az acr login –name mycontainerregistry |
| Push Image | docker pull mcr.microsoft.com/hello-world | |
| Tag Image | docker tag mcr.microsoft.com/hello-world <login-server>/hello-world:v1 | docker tag mcr.microsoft.com/hello-world mycontainerregistry.azurecr.io/hello-world:v1 |
| Push Image | docker push <login-server>/hello-world:v1 | |
| Run Image from Registry | docker run <login-server>/hello-world:v1 |
2 – Sign in, VSC and verify Docker Images
| 2 – Sign in, VSC and verify Docker Images | Check the images in VSC |

3 – Check prerequisites (docker version)
| 3 – Check prerequisites; | docker –version |

4 – Create and build image; to simply starts that app;
| 4 – Create and build image; to simply starts that app; | use (Docker Images: Build Image),<acr-name>.azurecr.io/<image-name>/<tag> |

5 – Deploy to container registry;
| 5 – Deploy to container registry; | Select Docker Images and Push, select mycintainerregistryrk.azurecr.io/dockerfile/1.0:latest |
<acr-name>.azurecr.io/<image-name>/<tag>
mycintainerregistryrk.azurecr.io/dockerfile/1.0
Executing task:
docker build –pull –rm -f “dockerfile.dockerfile” -t
mycintainerregistryrk.azurecr.io/dockerfile/1.0 “.”




6 – Deploy to App Service;
| 6 – Deploy to App Service; | In the REGISTRIES explorer, expand the image, right-click the tag, and select Deploy image to Azure App Service. |


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.
Validate

Code behind:
Understanding Dockerfile
Containerize an app with Docker tutorial – .NET | Microsoft Learn
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /App
# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore # Build and publish a release
RUN dotnet publish -c Release -o out # Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /App
COPY --from=build-env /App/out .
ENTRYPOINT ["dotnet", "DotNet.Docker.dll"]
| # Build Stage | uses the .NET SDK to install any required dependencies and build the project before publishing it to a folder named out | |
| FROM | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | |
| WORKDIR | ||
| COPY | ||
| RUN | ||
| # Serve Stage | uses the ASP.NET Core runtime image to run the application from the specified working directory, which is app in this case. |
Conclusion
Containerizing .NET applications using Docker provides numerous benefits, including portability, scalability, and an immutable infrastructure. By following the steps outlined in this post, you can easily deploy your .NET apps in custom containers on Azure App Service or locally using Docker.
Whether you are developing or deploying .NET applications, containerization offers a flexible and powerful solution for managing and scaling your applications.
Happy coding! 🚀🐳
