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 the part 1 of this series.
When you deploy dotnet 2.0 application to Web Apps, there are two choices.
- Use docker container
- Use dotnet 2.0 runtime
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.
5. Create new resource group and app service plan. One caveat here.
- Web Apps on Linux requires App Service plan for Linux, which requires separate resource group.
- There is no "Free" plan for Linux platform.
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.
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>
As we can deploy via Git, we can easily deploy via Visual Studio 2017 or shell.
I already deployed the application to App Engine in part 1. Is there anything I was missing? Of course. In this article, I just add one more information.
As tested in part 1, it is straight-forward to deploy to App Engine Flexible. But if you want to customize the environment, you can do so.
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. For example, you can specify how many instances you want and resource for each instance.
runtime: aspnetcore env: flex manual_scaling: instances: 3 resources: cpu: 2 memory_gb: 2.3 disk_size_gb: 10
It's interesting to find that experience varies even in same platform. I strongly felt that I cannot avoid container technology as a developer.