In this article, I explain how you can deploy your dotnet core web application to Azure and GCP as C# developer.
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.
- Azure and GCP subscription.
- Windows 10 and Visual Studio 2017 with Azure Development workload.
- dotnet core SDK.
- Basic Understanding of either cloud platform.
When I develop C# application, I use Visual Studio 2017. Both Azure and GCP provides IDE integration.
It's included as part of Azure Development workload. In you missed it, add it via Visual Studio Installer.
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 which is used by the extension.
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.
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 and assign billing information to the project.
1. Open Visual Studio 2017 and create new project.
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".
Now the application is created, let's deploy to each cloud platform.
There are several ways to deploy the app, but let's do the simplest one.
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.
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.
gcloud app create --region=us-central
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.
Okay, the first version is deployed. Let's update the application to see how the versioning works in each cloud.
You can change anything. I just changed the title the index.cshtml.
Azure provides "slots" to host different versions and let you "swap" the application to switch versions.
The thing is, "Free" version doesn't offer this capability, so lets change it.
1. Go to Azure Portal and select "Resource groups".
Now we have new slot, let's deploy it.
1. Right click the project and click "Publish".
GCP has versioning feature by default.
1. Right click project and click "Publish to Google Cloud", and select "App Engine Flex".
3. Once publish completed, go to Google Cloud Platform Console and select "App Engine" from menu.
As you may realize, GCP let us run multiple versions at same time by splitting traffic so that we can do A/B test.
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.