📺 Watch the video : How to deploy ASP.NET application to Docker Hub and Azure.
💡 Learn more : Azure App Service Web App for Containers
Running your application in a container is a great way to make sure that it can run anywhere and that its environment is the same, regardless of where you run it. You can run almost any type of application in a container and you can run containers almost anywhere. Azure has a lot of options for running containerized applications. One of those is Azure App Service Web App for Containers. This is a service that can run a container on the App Service platform, which gives you some of the PaaS features like deployment slots and easy authentication. Let's take a look at how to containerize an ASP.NET Core application with Visual Studio and host it in Docker Hub. And then let's take a look at how to deploy that container to Web Apps for Containers and run it in Azure.
Before you get started, you need to make sure that you have all of the prerequisites to follow along.
We'll create a new ASP.NET Core web application and make sure that it can run in a Windows container. Once we've created this, we'll host the container image in Docker Hub so that we can use it later in Azure.
(Add Docker support in Visual Studio)
FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build
These images are for .NET Core 2.1, but you can also use images for later versions of .NET Core.
(Publish to Docker Hub from Visual Studio)
You should now be able to see the container image in Docker Hub.
(Container image in Docker Hub)
Now that we have a container in Docker Hub, we can run it in Azure App Service Web Apps for Containers.
(Create Web App blade in the Azure portal)
(Configure container blade in the Azure portal)
(Application running in a browser)
You can now use the application, which is running in a Windows container in Azure Web Apps for Containers.
Visual Studio makes it very easy to containerize applications and publish them. Once published, it is very easy to use a container image in a service like Azure App Service Web Apps for Containers. And the cool thing is that the app runs in a container, even when it is running in Azure. This means that it is the exact same thing that you run locally. So if it runs locally it will also run in Azure. Also, Web Apps for Containers comes with some cool features, like the ability to use deployment slots, which means that you can publish a new version of your app in a slot and test it. And once you are ready, you can swap the slot into production with almost no downtime. And, as you saw in this post, you can use Windows containers in Web Apps for Containers. You can also use Linux containers if you want. Go and check it out!