ASP.NET Core on Section
Learn how to run a sample ASP.NET Core app at the edge for low latency and high availability. You can use our repo as a template, or perform the steps yourself using the Kubernetes dashboard or kubectl commands.
Step by Step
Following are step-by-step instructions to deploy a ASP.NET Core sample application to the edge on Section. We'll Dockerize it, and deploy it on Section.
- You need Docker installed so that you can build a docker image.
Create the ASP.NET Core App
Create a new directory for your app.
Download or clone the Microsoft ASP.NET Core dotnet/dotnet-docker repository from GitHub.
Then place the contents of the
aspnetapp directory in your
Let's build the container image that we'll deploy to Section. First make a
Dockerfile in your directory with the following content.
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
# copy csproj and restore as distinct layers
COPY aspnetapp/*.csproj .
RUN dotnet restore --use-current-runtime
# copy everything else and build app
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app --use-current-runtime --self-contained false --no-restore
# final stage/image
COPY /app .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
Build and tag it.
docker build . -t ghcr.io/YOUR_GITHUB_USERNAME/my-aspcorenet-app:prod
Launch it locally to test it.
docker run -p 8000:80 ghcr.io/YOUR_GITHUB_USERNAME/my-aspcorenet-app:prod
Push it to GitHub Packages. This makes it available to Section.
docker push ghcr.io/YOUR_GITHUB_USERNAME/my-aspcorenet-app:prod
Be sure to make it public. To see your packages and make this change, visit
Next, use the Create Project command in the Section Console in order to deploy your new container. Use the image name
ghcr.io/YOUR_GITHUB_USERNAME/my-aspnetcore-app:prod with port 8000.
See the pods running on Section's network with either the Kubernetes dashboard or
kubectl get pods -o wide. The
-o wide switch shows where your app is running according to the default AEE location optimization strategy. Your app will be optimally deployed according to traffic. In lieu of significant traffic, your deployment will be made to default locations.
kubectl logs POD to see the log message reporting that the server is listening on port 8000:
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
Hosting environment: Production
Content root path: /app
See What You've Built
See the sample app you've built by visiting the
YOUR.DOMAIN.COM according to your DNS and HTTPS configuration.