Azure vs GCP part 3: Compare Web Apps and App Engine as Linux platform
Tags: azure, gcp, cloud
Published: 2018-03-02 13:46:28

---
title: "Azure vs GCP part 3: Compare Web Apps and App Engine as Linux platform"
published: true
description: In this series, I compare Azure and GCP as C# developer
tags: azure,gcp,cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/m57mmv4hgz9xrskaital.PNG
---

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.

# .NET support

As it's Linux, only dotnet core is supported. I use same application I use in the [part 1](https://dev.to/kenakamu/azure-vs-gcp-part-1-aspnet-developer-experience-22i) of this series.

# Deploy to Azure Web Apps on Linux
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.

#### Docker for Windows
Windows now supports docker, but you need to install it.
[Docker for Windows](https://docs.docker.com/docker-for-windows/install/#download-docker-for-windows). You need hardware which supports Virtualization. I believe most PC does now though.

## Deploy as docker container

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.
![docker](https://thepracticaldev.s3.amazonaws.com/i/qzamsot4zfy6emr8fpm0.PNG)

2\. Select "Linux" as Target OS.
![docker](https://thepracticaldev.s3.amazonaws.com/i/wj70uf4bmfxqpuur5m6q.PNG)

3\. Now the solution has docker-compose project. Right click project and click "Publish". Click "Create new profile".
![publish](https://thepracticaldev.s3.amazonaws.com/i/us34vey7l0s9xmyt6z90.PNG)

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".
![publish](https://thepracticaldev.s3.amazonaws.com/i/lbw0h9e6wvv4ffaj1f0u.PNG)

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.

So I specify new resource group and "S1" app service plan here. Please note the app service plan name as you use it later.
![publish](https://thepracticaldev.s3.amazonaws.com/i/yt85npei6b643o6pnhgx.PNG)

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.
![publish](https://thepracticaldev.s3.amazonaws.com/i/9rlzm7lubacoryav5mty.PNG)

7\. Once deploy completed, access to the Site URL.
![publish](https://thepracticaldev.s3.amazonaws.com/i/fwnnyt66y8cpb7xdjngq.PNG)

## Deploy to dotnet core 2.0 runtime
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](https://portal.azure.com) and click "Cloud Shell" icon on top menu bar.
![portal](https://thepracticaldev.s3.amazonaws.com/i/4e79tdvat61ji1x5xkdz.PNG)

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. 

```shell
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://108bones@dotnetcoreonlinux123.scm.azurewebsites.net/dotnetcoreonlinux123.git

4\. Run following command to create deploy user. The username needs to be globally unique.

```shell
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".
![git](https://thepracticaldev.s3.amazonaws.com/i/qo90882axxy9elfb1i2r.PNG)

6\. Go to "Team Explorer" and click "Sync".
![git](https://thepracticaldev.s3.amazonaws.com/i/8qg5u7207efhnhgi2iu7.PNG)

7\. Select "Publish Git Repo".
![git](https://thepracticaldev.s3.amazonaws.com/i/7kksu3q1d080v5kuy07t.PNG)

8\. Enter the git address you obtained in previous step and click "Publish".
![git](https://thepracticaldev.s3.amazonaws.com/i/7te3ar7o41qt4h94cost.PNG)

9\. Enter username and password you set in previous step, and wait until push completes. It takes time for initial push. 
![git](https://thepracticaldev.s3.amazonaws.com/i/7r6d5bxrax0ezpuovfis.PNG)

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.
![git](https://thepracticaldev.s3.amazonaws.com/i/cptt3bq1sy8y48oz2t0l.PNG)

As we can deploy via Git, we can easily deploy via Visual Studio 2017 or shell.

# GCP App Engine Flexible
I already deployed the application to App Engine in [part 1](https://dev.to/kenakamu/azure-vs-gcp-part-1-aspnet-developer-experience-22i). Is there anything I was missing? Of course. In this article, I just add one more information.

## Customize App Engine Flexible environment.
As tested in [part 1](https://dev.to/kenakamu/azure-vs-gcp-part-1-aspnet-developer-experience-22i), 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.
![app](https://thepracticaldev.s3.amazonaws.com/i/vo1zwn2dfzfmyp9aqcep.PNG)

2\. Right click Project and select "Generate app.yaml and Dockerfile". 

![publish](https://thepracticaldev.s3.amazonaws.com/i/qac3n5oxeocruqua5l3r.PNG)

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.

```yaml
runtime: aspnetcore
env: flex

manual_scaling:
  instances: 3
resources:
  cpu: 2
  memory_gb: 2.3
  disk_size_gb: 10
```

# Summary
It's interesting to find that experience varies even in same platform. I strongly felt that I cannot avoid container technology as a developer. 

# References

[Introduction to Azure App Service on Linux](https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-intro)
[Deploy an ASP.NET container to a remote Docker host](https://docs.microsoft.com/en-us/azure/vs-azure-tools-docker-hosting-web-apps-in-docker)
[Configuring your App with app.yaml](https://cloud.google.com/appengine/docs/flexible/dotnet/configuring-your-app-with-app-yaml) 


Ken