.Net Core Kubernetes “Hello World” API Project

I never learned anything just by simply reading a book or online course. I learn best doing hands-on exercises.

So, recently, I just got Visual Studio 2019 installed, and I thought, what else could be better to try out on the new VS 2019 than trying out Azure Kubernetes Service (AKS)? I happen to be researching about microservices as well. Kubernetes API should be a good “Hello World” project for me.

My “Hello World” API project will be very simple:

  • .NET core API running in a Container
  • Products end-point: return list of products
  • products-list hard-coded in the app (simplify it by skipping data storage)
First, create a new project and pick Container App for Kubernetes

My hard-coded Products end-point

I press the Azure Dev Spaces button (where the Debug button normally is):

And I get prompted by this:

AKS Cluster not setup

I click the Create a new AKS cluster hyperlink and it goes to Microsoft:


It provides 2 Azure Shell commands:

  1. Create resource group
  2. Create the Kubernetes cluster at a resource group

Creating the resource-group using the Azure Shell CLI worked fine:

But I got an error with the create-kubernetes-cluster command: An RSA key file or key value must be supplied to SSH Key Value. You can use –generate-ssh-keys to let CLI generate one for you

I got the error in Azure Shell, so I try the Portal UI instead (I’m not going to monkey around trying to make this command work).

Resource Group already visible in my Azure. I proceed with adding the Kubernetes cluster:

Create Kubernetes cluster

Create Kubernetes cluster – validation passed
Kubernetes Cluster Deployment Complete

I go back to Visual Studio 2019, now, the AKS is available in the dialog box:

I thought it’s done but it’s not yet ready: next, Enable Azure Dev Spaces:

After what felt like an eternity (5 minutes or so), updates on the Azure Dev Spaces Output in Visual Studio:

But it’s not done yet! More updates in output (green progress indicator still going)….

About 10 minutes later—finally—service is up for debugging locally!!

About 15 minutes to create the AKS cluster.

Another 15 minutes or so to provision the container.

30 minutes all-in-all before I could fire up my service and see it for the first time in action!

I stop the debugging. I edit the code. I want to see how long it takes to redeploy updated code. Add a “Bread product” into the get-products end-point (I sloppily duplicated the hard-coded ID 2 for Eggs and Bread – oh well):

I debug again.

Debug was pretty instantaneous by this point…only couple of seconds to fire up.

I shutdown and totally close Visual Studio 2019. I want to see how fast I can fire up VS 2019, open the solution, and debug the microservice. No lag and it started the debugging session just like it normally would. 

Great. It was only slow on the initial provisioning.

Where are the specs for the Azure Kubernetes Service (AKS)? Open up launchSettings.json (under Properties in Solution Explorer tree). Not only is the AKS name here, but the resource group as well:

About 40 minutes effort to create my “Hello World” Kubernetes app, provision Azure stuff, and debug my microservice.

Later, I’ll explore what this would be like to open the solution on another Visual Studio (another machine), and debug it. I see the AKS and resource-group names, and the subscription ID. But, I’m curious to see what the initial experience is from another VS instance would be like.

Be the first to comment

Leave a Reply

Your email address will not be published.