So far I just deployed dotnet core web application to Azure and GCP without thinking about underline OS. Therefore, naturally, I deployed my app to Windows hosted environment in Azure. In this article, I use Web Apps on Linux to see how they are different.
As it's Linux, only dotnet core is supported. I use same application I use in thepart 1 of this series.
When you deploy dotnet 2.0 application to Web Apps, there are two choices.
Let's see how docker container deployment works. By the way, I couldn't successfully deploy to dotnet 2.0 runtime environment but I will explain steps anyway.
Windows now supports docker, but you need to install it.
Docker for Windows . You need hardware which supports Virtualization. I believe most PC does now though.
1. To use docker, you need to enable it. This could be done at project creation time or later like this article. Right click project | Add | Docker Support.
2. Select "Linux" as Target OS.
3. Now the solution has docker-compose project. Right click project and click "Publish". Click "Create new profile".
4. Visual Studio 2017 detects docker support and gives us Linux (or even Container Registry) option. Select "Microsoft Azure App Service Linux" and click "Publish".
5. Create new resource group and app service plan. One caveat here.
So I specify new resource group and "S1" app service plan here. Please note the app service plan name as you use it later.
6. Then just wait. This takes a bit of time, so grab coffee if you want. Meanwhile, Visual Studio creates resources in Azure, push image to registry, and deploy it.
7. Once deploy completed, access to the Site URL.
Web Apps also provides dotnet core 2.0 runtime environment. It works pretty same as Windows environment. However, Visual Studio doesn't support direct push like docker version.
Let's create new Web Apps by re-using the resource group created above. I use CLI capability embedded in portal.
1. Go to Azure Portal and click "Cloud Shell" icon on top menu bar.
2. Run following command to create new Web Apps on Linux. Replace plan name to you created above. And Web App name needs to be globally unique. The '--deployment-local-git' parameter tells the Web Apps that I use git push to deploy.
rgname=CloudCompareLinuxRG planname=WebApplication120180302090521Plan webappname=dotnetcoreonlinux123 az webapp create -g $rgname -p $planname --name $webappname --runtime "dotnetcore|2.0" --deployment-local-git
3. Copy the git url which is displayed right after the last command. Address looks like below.https://firstname.lastname@example.org/dotnetcoreonlinux123.git
4. Run following command to create deploy user. The username needs to be globally unique.
az webapp deployment user set --user-name <username> --password <password>
5. If you didn't initialize git yet, right click solution and select "Add Solution to Source Control".
6. Go to "Team Explorer" and click "Sync".
7. Select "Publish Git Repo".
8. Enter the git address you obtained in previous step and click "Publish".
9. Enter username and password you set in previous step, and wait until push completes. It takes time for initial push.
Well, this should work, but I encounter an issue that I couldn't successfully deployed by using this method. I may miss something or temporary issue? Anyways this is the error I got.
As we can deploy via Git, we can easily deploy via Visual Studio 2017 or shell.
I already deployed the application to App Engine inpart 1. Is there anything I was missing? Of course. In this article, I just add one more information.
As tested inpart 1, it is straight-forward to deploy to App Engine Flexible. But if you want to customize the environment, you can do so.
1. As I already mess up the project by adding docker support in previous step, let's re-create new application from scratch. I created "WebApplication2" project.
2. Right click Project and select "Generate app.yaml and Dockerfile".
3. app.yaml and DockerFile are created.
Then you can modify the file and publish. See Configuring your App with app.yaml for more detail.
It's interesting to find that experience varies even in same platform. I strongly felt that I cannot avoid container technology as a developer.