Introduction As web developers, we used to find appropriate hosting for our applications with all the complications of deploying and maintaining them. But now, we live in a new era when cloud providers can make a lot of things for us at almost no cost. As for .NET developers, Microsoft Azure looks most natural choice to host web applications. Docker is another piece of technology that makes it possible to abstract from the platform and environment you are running your application. In this article, I will give a detailed guide on how to create a simple ASP.NET Core web application, create a docker image with your application, and the easiest way to deploy it to Azure. In the end, you will have a good understanding of how to deploy your web application and make it accessible to the whole world. 1. Create ASP.NET Core Web App I’m going to use JetBrains Rider for the purpose of the development in this article. But you can use any tool you want. First, you need to create a new project. Let’s call it simple ‘ ’. webapp After creating a new project, it should look like this: 2. Create a Docker Image Without any changes in the project, we are going to focus on the . Modify it as the following example: Dockerfile FROM mcr.microsoft.com/dotnet/aspnet:6.0 as base WORKDIR /app EXPOSE 8080 ENV ASPNETCORE_URLS http://+:8080 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build COPY . /src WORKDIR /src RUN dotnet build "webapp.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "webapp.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "webapp.dll"] You need to pay attention to the lines and to be able to connect via HTTP to the docker container. EXPOSE 8080 ENV ASPNETCORE_URLS http://+:8080 Build a docker image from the command line. You need to navigate to the project directory, and execute the following command: webapp DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64 --tag drmoz/webapp:latest . I’m running it on Mac M1, and I have to specify parameter explicitly to be compatible with Azure deployment. I also have to activate the Docker Buildkit by specifying the parameter and using to be able to build an image for another architecture. --platform DOCKER_BUILDKIT=1 buildx If you are running it on the Intel x86/x64 platform, you can use command without the need to specify parameter and activate . docker build --platform buildx You can tag your image differently, but since I’m going to use Docker Hub, I have to specify my account name: as part of the image tag . drmoz drmoz/webapp:latest When an image is built, you can check if it is present in the Docker by running the following command: docker images It should be on the list: REPOSITORY TAG IMAGE ID CREATED SIZE drmoz/webapp latest 0cfac748256b 37 minutes ago 216MB Let’s run the docker container to verify that the newly created image works fine. Execute command to start a container: docker run docker run -p 5555:8080 drmoz/webapp:latest Specify the parameter to map the port inside the container to your local machine port. Also, specify the image name to create the container. In my case, it is . -p 8080 5555 drmoz/webapp:latest Now, you can navigate in your browser to see the ASP.NET Core Web App home page. http://localhost:5555 We need to push an image to the . Before that, you must register on the Docker Registry, and create a repository. Click on the ‘ ‘ button on the right corner of the home page. Docker Hub Create repository Specify the field, and keep the repository visibility . Repository Name Public In the command line, you have to log in to the Docker Hub registry: docker login After that, you will be able to push a newly created image to the registry: docker push drmoz/webapp:latest Navigate to the repository, and you will see the information about the image: 3. Create a Web App in Azure Now, we are ready to deploy our ASP.NET Core Web Application to Azure. Let’s log in to the Azure Portal, and create a new resource group. Specify the Resource Group name as ‘ ’, and click the ‘Review + create’ button. webapp-rg On the next screen, just hit the ‘Create’ button. Now, we can create a Web App. Navigate to the ‘Create resource‘ page, and find WebApp. Click the ‘Create’ button. You need to specify the one that we created previously. Also, specify a unique for the Web App. Select ‘Docker Container’ in the field. Later, we will be able to specify which Docker image to use. Resource Group Name Publish Select any suitable options in the section, but I recommend using a tire for test purposes. Navigate to the Docker tab. Pricing plans Free F1 On this tab, select ‘Docker Hub’ in the field. Select ‘Public’ in the field, and specify the value with the name of the image we pushed to Docker Hub. Navigate to the ‘Review + create’ tab. On this tab, click the ‘Create‘ button: Image Source Access Type Image and tag When the new resource is deployed, you will be asked if you would like to navigate to this resource; just do it. You will be able to see information regarding the Web App. Click on the ‘Browse‘ button to open a deployed web application. If everything went correctly, you should see the ASP.NET Core Web App home page similar to the one you saw in your browser by navigating . http://localhost:5555 Enable Continuous Deployment If you navigate to the ‘Deployment Center’ settings and enable ‘Continues deployment’, you will be able to redeploy your image every time you push a new one to the Docker Hub. In that manner, you can make changes to your code, push it to the Docker Hub with a new image, and see changes in minutes in Azure. Azure Web App Troubleshooting To be able to see deployment logs and identify issues, you need to enable saving logs to the file system under the ‘App Service logs’ chapter as follows: When it is done, you can navigate to the ‘Deployment Center’ and see logs as follows: Summary If you reach this point, you managed to create an ASP.NET Core web application; pack it to the Docker image, and deploy it to Azure. Nowadays, technology makes life easier and speeds up the development process. You can see how easily you can deploy your application to the cloud provider and expose it to the whole world, perform some testing, and see the result of your work. Now, you can dive into the details of Azure cloud providers using Microsoft . Also, take a look at the Docker for a deeper understanding of this piece of technology. I hope it might be helpful. documentation documentation