Skip to main content
This guide shows how to create, run, and containerize a simple ASP.NET Core Razor Pages app so you can test it locally (on a single-node Kubernetes cluster via Docker Desktop) before deploying to AKS. Prerequisites
For local Kubernetes testing, enable Kubernetes in Docker Desktop Settings. That boots a single-node cluster suitable for development and learning.
Docker Desktop has licensing terms. Using it for local learning and development is typically allowed, but review the license if you plan production or commercial use.
Verify .NET SDK Run this to confirm .NET 6 is installed:
Create the ASP.NET Core app
  1. Open your IDE.
  2. Create a new solution using the “ASP.NET Core Web Application” template.
  3. Give the solution a name (for example, KodeKloudApp) and choose the option to put the solution and project in the same directory so the solution contains a single project.
  4. When creating the project, let the IDE generate a Dockerfile. We’ll use Linux containers for the runtime.
A Windows desktop screenshot showing JetBrains Rider's "New Solution" dialog configured for an ASP.NET Core Web Application, with the "Put solution and project in the same directory" option highlighted. Desktop icons for Recycle Bin, Docker Desktop and JetBrains Rider are visible on the left.
Modify the app to read configuration We’ll modify the Index page model to read a Message value from configuration sources (appsettings.json or environment variables). This keeps configuration flexible when running locally or in containers. Update Pages/Index.cshtml.cs:
Add the Message key to appsettings.json A minimal appsettings.json with the Message key:
Update the Index Razor page to render the message Edit Pages/Index.cshtml to display @Model.Message:
Run and verify locally
  • Start the app from your IDE (or dotnet run from the project folder).
  • The page should show the Message from appsettings.json.
  • Change the value in appsettings.json (for example, to "Hello World changed") and restart the app to see the new text.
Example updated appsettings:
Building a Docker image (multi-stage Dockerfile) The IDE-generated Dockerfile typically uses a multi-stage build:
  • Build stage uses the .NET SDK to compile and publish.
  • Final stage uses a smaller ASP.NET runtime image to reduce final image size.
Example multi-stage Dockerfile:
Build the Docker image From the project root (where the Dockerfile is present):
Example build output (truncated):
Verify the image exists locally:
If you prefer not to build locally, a pre-built image used in this lesson may be available on Docker Hub so you can follow the Kubernetes deployment steps without rebuilding. Quick reference: changed files and commands Links and references This app is now ready to be deployed to your local Kubernetes cluster or pushed to a container registry for AKS or other environments.

Watch Video