Google Cloud for ASP.NET Core Web Apps

I have made a series of tutorials that will help you get started on working with GCP for ASP.NET Core Web Application development.

Google Cloud for ASP.NET Core Web Apps – TutLinks
Google Cloud for ASP.NET Core Web Apps – TutLinks

Table of Contents

About the Web App

The series majorly focuses on an ASP.NET Core MVC Web App (.NET 6).

  • This web app has EF Core ORM that talks to a PostgreSQL database.
  • The Web app also has the facility to upload image files.
  • The App will be packaged as an container image targeting Linux OS that can be run on any environment that has Linux OS as a container.

The following screen shows how the application looks after the series of tutorials.

Google Cloud for ASP.NET Core Web Apps – TutLinks
Google Cloud for ASP.NET Core Web Apps – TutLinks

Cloud features used

To deploy our ASP.NET Core Web App, we will be using the following Service offerings or features available

  • Cloud SQL for PostgreSQL Database Instance
  • Cloud Storage with a Bucket to save files uploaded to the web app.
  • Cloud Run to host the ASP.NET Core MVC Web application
  • Cloud Build with Triggers for Continuous Delivery of application to a service on Cloud Run
  • Secret Manager to store application specific secrets and keys.
  • Domain mappings to map a custom domain to the our Web App running as a service on Cloud Run

A very methodical approach is followed in order to present the audience the best knowledge of how to work with Google Cloud Platform for applications built using ASP.NET Core.

If you are not a developer or a seasoned software engineer, this tutorial series is for both. The series starts with basic development environment set up and then takes you through developing the ASP.NET Core MVC Web App (.NET 6) that uses Razor Views, Entity Framework Model and MVC Controllers.

The Series has 5 realtime demonstrations as follows:

  1. How to install PostgreSQL (latest) without Admin Rights on Windows 11 OS
  2. Working with Google Cloud Storage for ASP.NET Core 6 Applications (Hands-on Tutorial)
  3. How to create Cloud SQL Postgres Db Instance on Google Cloud Platform and Connect with PgAdmin4
  4. How to Deploy ASP.NET Core MVC Web App (.NET 6) on Google Cloud Run using Cloud Build
  5. How to Map a Custom Domain to Google Cloud Run Service

So, following along with the series in the sequence mentioned below and gain Hands-On experience on Deploying ASP.NET Core web applications are Google Cloud Platform.

1. How to install PostgreSQL (latest) without Admin Rights on Windows 11 OS

In this tutorial we will see how to Install and Set up PostgreSQL on Windows for a normal user without Admin Privileges. Most of the IT corporations doesn’t grant admin privileges to install software. But being a software engineer, we would always like to explore new technologies. Admin privileges should not become a barrier to install new tech stack or a software package and thus hamper the limitation to explore it. So let’s see how to install PostgreSQL database without actually needing admin privileges.

This approach works for both Windows 10 & Windows 11 operating systems.

This tutorial covers the following contents.

  • Install PostgreSQL without admin rights
  • Add PostgreSQL binaries to the user Environment Variables
  • Initialize a PostgreSQL database server
  • Start a PostgreSQL database server from command prompt
  • Connect to a PostgreSQL server using pgAdmin 4
  • Create a database using pgAdmin4
  • Create a table using pgAdmin4
  • Stop or restart the PostgreSQL database server from command prompt

Video Tutorial Link: How to install PostgreSQL (latest) without Admin Rights on Windows 11 OS

2. Working with Google Cloud Storage for ASP.NET Core 6 Applications (Hands-on Tutorial)

In this detailed video, we will learn how to work with Google Cloud Storage for ASP.NET Core 6 Web applications. This is the real time demonstration of performing file based CRUD operations directly on to the Google Cloud Storage. You can follow along with this tutorial if you have a GCP account. It’s free to sign up and you will get $300 Credit if you sign up with your credit card.

The file CRUD operations on a Google Cloud Storage Bucket demonstrated in this video performs the following in a step-by-step approach with real demonstration.

  • Create – Uploading a file to Google Cloud Storage Bucket,
  • Read – Retrieving a signed URL of a file from GCS Bucket,
  • Update – Delete and Upload a.k.a replace a file in GCS Bucket
  • Delete – Removing a file from a GCS Bucket

This real-time Hands on tutorial is divided in to four parts as described below.

  • Part 1 – GCP Setup
  • Part 2 – Create and Set up ASP.NET Core 6 MVC with EF Core project
  • Part 3 – Implement Cloud Storage Service to perform upload, delete and read files from GCP Cloud Storage
  • Part 4 – Implement MVC application to handle file uploads on GCP Cloud Storage
  • Part 4.1 – Implement MVC for Create View with File Upload functionality to Cloud Storage
  • Part 4.2 – Implement MVC for Details View with Show file from Signed URL of a file in Cloud Storage
  • Part 4.3 – Implement MVC for Edit View with File Delete & Upload (replace) functionality to Cloud Storage
  • Part 4.4 – Implement MVC for Delete View with File Delete functionality from Cloud Storage

Video Tutorial Link: Working with Google Cloud Storage for ASP.NET Core 6 Applications (Hands-on Tutorial)

Detailed Article: Working with Google Cloud Storage for ASP.NET Core 6 MVC Application using Entity Framework Core 6

3. How to create Cloud SQL Postgres Db Instance on Google Cloud Platform and Connect with PgAdmin4

In this tutorial we will look at how to create Cloud SQL Postgres Database Instance on Google Cloud Platform (GCP).

We will also look at how to access this remote Cloud SQL Postgres Database Instance on GCP from the local PC with the help of PgAdmin4.

Contents of this tutorial include the following.

  • Login to the GCP
  • Create a new Project
  • Enable Cloud Engine API
  • Create Cloud SQL database of type PostgreSQL
  • Instance Info
  • Choosing a Configuration to start with
  • Customize your Instance
  • Choosing the Machine Type
  • Choosing the Storage Type
  • Configuring Connections on a Cloud SQL Database Instance
  • Authorize Client IP address of local PC on Cloud SQL Database Instance
  • Defining Data Protection on Cloud SQL Instance
  • Defining Maintenance window for Cloud SQL Instance
  • Resources for Installing PgAdmin on Local PC
  • Navigating to Cloud SQL Database Instance
  • Reset Forgot Password or Change Password of Database User on Cloud SQL
  • Create Database User
  • Register a Server on PgAdmin that connects to Cloud SQL on GCP
  • Create a database on Cloud SQL Database Instance from PgAdmin
  • Verify DB Created on Cloud SQL Instance from GCP
  • Delete a database on Cloud SQL Database Instance from PgAdmin
  • Verify DB Deleted on Cloud SQL Instance from GCP

Video Tutorial Link: How to create Cloud SQL Postgres Db Instance on Google Cloud Platform and Connect with PgAdmin4

4. How to Deploy ASP.NET Core MVC Web App (.NET 6) on Google Cloud Run using Cloud Build

In this tutorial, we will see a methodical way to implement (CD) Continuous Deployment of an ASP.NET Core MVC Web App (.NET 6) on Google Cloud Run with the help of Google Cloud Build Trigger.

This tutorial is continuation of the previous part https://youtu.be/7tAAGnSbfCc which explains how to work with Google Cloud Storage for ASP.NET Core 6 Applications (Hands-on Tutorial)

By the end of this tutorial, you will be able to have a full understanding of enabling Continuous Delivery of ASP.NET Core applications to Cloud Run via Cloud Build.

This tutorial covers in-depth concepts of working with Cloud Build triggers, Cloud Run features such as Logs, Revisions, SLOs etc.

The tutorial also helps you understand how to troubleshoot the Continuous Deployments on Cloud Run.

This tutorial comprises of the following contents.

  • Create a Project on GCP
  • Enable APIs & Services
  • Create Cloud SQL for PostgreSQL
  • Create Storage Bucket
  • Create cloudbuild.yaml
  • Dockerfile Walkthrough
  • Manage Cloud SQL for PostgreSQL & Apply EF Core Migrations to Remote DB
  • Create Secrets in Secret Manager
  • Create Service Account with role Storage Object Admin
  • Create Cloud Run
  • Add Cloud SQL Connection to Cloud Run
  • Reference Secrets to Cloud Run
  • Troubleshoot Cloud Build Trigger
  • Setup Continuous Deployments for Cloud Run
  • Understanding Cloud Build Details and Build Summary Steps
  • Navigating through Deployed ASP.NET Core 6 MVC with EF Core app on GCP
  • Defining SLOs for your Service on Cloud Run
  • Observing Logs
  • Making sense of Revisions of your Service on Google Cloud Run

Video Tutorial Link: How to Deploy ASP.NET Core MVC Web App (.NET 6) on Google Cloud Run using Cloud Build

How to Map a Custom Domain to Google Cloud Run Service

Finally, this tutorial will help you learn how to Map a Custom Domain to Google Cloud Run Service.

The Custom domain is with Godaddy registrar, and the DNS management is delegated to Cloud Flare. We will first verify our domain ownership with GCP and then add a CName record to point our subdomain or custom domain to ghs.googlehosted.com.

Following are the contents covered in this tutorial.

  • Map Custom Domain for Cloud Run Service
  • Verify Domain Ownership with GCP
  • Add CName record in the DNS Settings
  • Access Cloud Run Service via Custom Domain

Video Tutorial Link: How to Map a Custom Domain to Google Cloud Run Service

If you find the series interesting, feel free share this article. Also please do subscribe to TutLinks for more such quality tutorials.

Navule Pavan Kumar Rao

I am a Full Stack Software Engineer with the Product Development experience in Banking, Finance, Corporate Tax and Automobile domains. I use SOLID Programming Principles and Design Patterns and Architect Software Solutions that scale using C#, .NET, Python, PHP and TDD. I am an expert in deployment of the Software Applications to Cloud Platforms such as Azure, GCP and non cloud On-Premise Infrastructures using shell scripts that become a part of CI/CD. I pursued Executive M.Tech in Data Science from IIT, Hyderabad (Indian Institute of Technology, Hyderabad) and hold B.Tech in Electonics and Communications Engineering from Vaagdevi Institute of Technology & Science.

Leave a Reply