Azure vs GCP part 1: Deploy ASP.NET core application experience
Tags: azure, gcp, cloud
Published: 2018-02-28 07:51:36

---
title: "Azure vs GCP part 1: Deploy ASP.NET core application experience"
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
---

In this article, I explain how you can deploy your dotnet core web application to Azure and GCP as C# developer.

# .NET support

It's quite obvious that Azure supports .NET. But GCP starts supporting .NET at least core version. Now, I can run my C# application in both cloud environment. But which one I should use? Rather than answering this question, I show you the developer experience as hand-on format.

### Prerequisites
- Azure and GCP subscription.
- Windows 10 and Visual Studio 2017 with Azure Development workload.
- dotnet core SDK.
- Basic Understanding of either cloud platform.

## Visual Studio 2017 support
When I develop C# application, I use Visual Studio 2017. Both Azure and GCP provides IDE integration. 

#### Azure Tools for Visual Studio
It's included as part of Azure Development workload. In you missed it, add it via Visual Studio Installer.

#### Google Cloud Tools for Visual Studio
1\. Install the extension to your Visual Studio from Tools | Extensions and Updates and search for "google".
![cgp tool](https://thepracticaldev.s3.amazonaws.com/i/co73shdxcm7dkvw459ll.PNG)

2\. Once installation completed, open Visual Studio 2017 and go to Tools | Google Cloud Tools | Show Google Cloud Explorer.

3\. Then configure your account by following the wizard.

4\. Next, install Google Cloud SDK from [here](https://cloud.google.com/sdk/) which is used by the extension.

5\. At the end of installation, make sure you checked "Run 'gcloud init' to configure the Cloud SDK.
![install](https://thepracticaldev.s3.amazonaws.com/i/pk1hoxk8v9n6ur7ge5ae.PNG)

6\. Follow the instruction to complete the initialization.

7\. Create a project in advance. Run the following command. Change the project value to make it unique.

```shell
gcloud projects create cloud-compare-2018 --name "cloud compare"
gcloud config set project cloud-compare-2018
```
8\. Once project completed, go to [Google Cloud Platform Console](https://console.cloud.google.com/billing/projects) and assign billing information to the project.

# Create dotnet core project
1\. Open Visual Studio 2017 and create new project.

2\. Select "ASP.NET Core Web Application.
![application](https://thepracticaldev.s3.amazonaws.com/i/njer8g0dgee69swvihwn.PNG)

3\. Select MVC applicaiton, or any template you want, and click OK. Azure already support Authentication Integration capability here, but keep "No Authentication" at the moment. VS also let us select "docker support", but as both cloud supports dotnet core runtime, go ahead to click "OK".
![mvc](https://thepracticaldev.s3.amazonaws.com/i/qaatgj271u60d5z6zel9.PNG)

4\. Press F5 to run the application locally.
![apptop](https://thepracticaldev.s3.amazonaws.com/i/egohm4yj9kumzmdmzy2c.PNG)

# Deploy
Now the application is created, let's deploy to each cloud platform.

### Azure
There are several ways to deploy the app, but let's do the simplest one.

1\. Right click the project and select "Publish".
![publish](https://thepracticaldev.s3.amazonaws.com/i/q9p4dpt5tbn45tkcmxse.PNG)

2\. Click "Publish" button by select "Azure" and "Create New".
![publish](https://thepracticaldev.s3.amazonaws.com/i/u5s3a2mushibn6t3ocx5.PNG)

3\. Sign In to Azure if you didn't yet, which loads subscriptions and related information.

4\. Enter the application name, and select Subscription. You can create new "Resource Group" and "App Service Plan" or select existing. I added new resource group and free plan. Click "Create".

- Resource Group: It's a logical grouping where you can put all your resources such as WebApps, VM, Storage, etc. It's almost equals to project in GCP.
- App Service Plan: It stores information such as CPU and memory size, supported features, and pricing. Each web app is linked to one app service plan.
![publish](https://thepracticaldev.s3.amazonaws.com/i/59jvdoq9pct2zfsbepvt.PNG)

5\. That's it. It automatically launches the application once published.
![publish](https://thepracticaldev.s3.amazonaws.com/i/sdq765rguduh5fm9ifn8.PNG)

### GCP App Engine Flex
steps are very similar to Azure.

1\. If this is your first time to deploy any application, you need to create App Engine application first. Open command prompt and run the following. You can change region if you want.

```shell
gcloud app create --region=us-central
```
2\. Once the application is created, select the project in Google Cloud Explorer.
![publish](https://thepracticaldev.s3.amazonaws.com/i/l3dyzgmlez9k1b2mstrh.PNG)

3\. Right click the project and select "Publish to Google Cloud".
![publish](https://thepracticaldev.s3.amazonaws.com/i/9ezp7v6nizoudbne9dea.PNG)

4\. Click "App Engine Flex". We test container later.
![publish](https://thepracticaldev.s3.amazonaws.com/i/r5x5ruvcg4v9jinsm07c.PNG)

5\. Enter Version Name and click "Publish". It takes more time than Azure as it creates and register container in the background, I believe.
![publish](https://thepracticaldev.s3.amazonaws.com/i/nd7ydrb3hex4xor37cbc.PNG)

6\. That's it. It automatically launch the application.
![publish](https://thepracticaldev.s3.amazonaws.com/i/8699l6880f9y69quf828.PNG)

Oh, wait. The application name becomes https://cloud-compare-2018.appspot.com/, and I didn't specify any. 

App Engine takes project name as it's URL.

# Versioning
Okay, the first version is deployed. Let's update the application to see how the versioning works in each cloud.

#### Update the application
You can change anything. I just changed the title the index.cshtml.

### Azure 
Azure provides "slots" to host different versions and let you "swap" the application to switch versions. 


#### Add slot
The thing is, "Free" version doesn't offer this capability, so lets change it.

1\. Go to [Azure Portal](https://portal.azure.com) and select "Resource groups".
![portal](https://thepracticaldev.s3.amazonaws.com/i/colkok3zidfzi10jgsxy.PNG)

2\. Select the resource you created and select "App Service Plan".
![portal](https://thepracticaldev.s3.amazonaws.com/i/iodq9r13fgrl21pwaor6.PNG)

3\. From the menu, click "Scale up (App Service plan)".
![portal](https://thepracticaldev.s3.amazonaws.com/i/pz5zw8qza08yj8l221f4.PNG)

4\. Select "S1 Standard" which has slotting capability and click "select".
![portal](https://thepracticaldev.s3.amazonaws.com/i/m12qxpntte9lb65mp1zz.PNG)

5\. Then, go to Web Application from Resource Group, and select "Deployment slots".
![portal](https://thepracticaldev.s3.amazonaws.com/i/60lq2ptdoizsecsy0zl2.PNG)

6\. Click "Add slot", then name it. You can select if you want to copy configuration, too. Click "OK" once you configured. keep this window as you use it again later.
![portal](https://thepracticaldev.s3.amazonaws.com/i/nkl8rz0y9lxvmwh383jn.PNG)

#### Deploy
Now we have new slot, let's deploy it.

1\. Right click the project and click "Publish".

2\. As I already publish it once, the "profile" already exist. Click "Create new profile".
![publish](https://thepracticaldev.s3.amazonaws.com/i/8xlbs6pe39g7zn0iwml4.PNG)

3\. Check "Select Existing" and click "OK".
![publish](https://thepracticaldev.s3.amazonaws.com/i/d98unlkpo9rawv80fj7r.PNG)

4\. Expand the existing resource group, down to slot and select newly created slot, and click "OK".
![publish](https://thepracticaldev.s3.amazonaws.com/i/si6kckb0l6apcxfpcftd.PNG)

5\. Click "Publish".
![publish](https://thepracticaldev.s3.amazonaws.com/i/uphqxjy9rgr1v7yuulc8.PNG)

6\. Once publish completed, we have two versions at the moment. On production slot and "slot1" slot. Go back to portal again, select the slot and click "Swap".
![publish](https://thepracticaldev.s3.amazonaws.com/i/moso483065x6zcxnxdqa.PNG)

7\. Select "Slot1" for source and "production" to destination and click "OK".
![publish](https://thepracticaldev.s3.amazonaws.com/i/8do11dtttqx8g9v9e1a8.PNG)

8\. Once swap done, open the page to confirm it has newer version.
![publish](https://thepracticaldev.s3.amazonaws.com/i/zd2kr6hmc5u5s4fpjxg5.PNG)

### GCP
GCP has versioning feature by default.

1\. Right click project and click "Publish to Google Cloud", and select "App Engine Flex".

2\. Confirm you have different version, check "Promote version" and uncheck "Publish".
![publish](https://thepracticaldev.s3.amazonaws.com/i/464mhzu71k8x611ql8v1.PNG)

3\. Once publish completed, go to [Google Cloud Platform Console](https://console.cloud.google.com/) and select "App Engine" from menu.
![publish](https://thepracticaldev.s3.amazonaws.com/i/cis4t3lyn8vc0ong2obd.PNG)

4\. Select "Versions" and confirm there are two versions.
![publish](https://thepracticaldev.s3.amazonaws.com/i/u74yjvncrqe1923dtizj.PNG)

5\. Select newer version and click "Split traffic".
![publish](https://thepracticaldev.s3.amazonaws.com/i/awfenacfowlhmkjnw4ho.PNG)

6\. Specify 100% for newer version and "Save".
![publish](https://thepracticaldev.s3.amazonaws.com/i/h1a1mis7q1dexsas21ip.PNG)

7\. Open the application to confirm new version is available.
![publish](https://thepracticaldev.s3.amazonaws.com/i/2ihm9ns1rsapyocuwcmk.PNG)

As you may realize, GCP let us run multiple versions at same time by splitting traffic so that we can do A/B test.

# Summary
Both cloud platforms provide similar experience and features. So which is better? I don't have the answer by looking into deployment experience, therefore I look into both platform deeper in the next article.