Deploying web app on Linux from Docker hub using Azure App Services
In this post we will see how to deploy a .Net Core application on Linux using Azure App services. We first build a Docker image from our application. Then we push this image to a public Docker Hub repository. Finally using web app on Linux from Azure App Services we pull our image and run it in a Linux container.
Before building our image, let create a public repository on Docker Hub. After login in to the Docker Hub account, let’s create a new public repository as shown in this screenshot.
Here all we need to enter is name of the repository and click on Create button.
Now that we have this repository created on Docker Hub, it is time to build an image from our .Net application. Here is the link to this .Net Core application on Github. Let’s build an image from this application by running below command on terminal:
As you can see the image was successfully built. Before pushing this image we need to tag it properly:
Let’s push this image using below command:
Inside Azure portal I want to create a new app service and this app service is going to be based on Linux.
So when I search for starting template for my app service, I am actually going to search for web app on Linux.
At the moment this is on previous and some features, pricing, and the locations where you can deploy this app service might change in the future.
After clicking on this item, on the view click on the Create button.
Once the configuration blade in the portal loads, you will see that I need to provide an app name.
I will call this app onlinuxwebappdemo so I will be able to reach this service by navigating to http://onlinuxwebappdemo.azurewebsites.net
I choose pay as you go subscription and I use the existing resource group for this app service. For app service plan, at the moment there is a restriction on the locations where I can use webapp on Linux. I use pre-generated option. Now I can configure the container of the app service. Here I have the ability to configure the environment that I am going to run my application by selecting it from the drop down list. For this demo I use .Net Core 1.1 and this gives me an environment that already has .Net Core installed.
For this particular demo, I want to show deployment from Docker Hub. I click on Docker Hub tab, and enter the name of my public image. If my image is private I need to provide the credential for that particular account in Docker Hub.
After deployment, in order to test the application I would navigate to below URL and as you can see my web api returns two strings.
Number of Views:2254