Deploy .NET
Deploy an ASP.NET Core application on Out Plane, with Kestrel and a managed database.
This guide deploys an ASP.NET Core application and connects it to a managed PostgreSQL database. For the shared deploy flow, see Deploy from GitHub.
Prepare Your App
Listen on 0.0.0.0
Kestrel binds to localhost by default, which is unreachable in a container. The simplest
fix is to set ASPNETCORE_URLS as an
environment variable, then expose the same port:
ASPNETCORE_URLS=http://+:8080Out Plane uses a fixed exposed port, so a fixed value such as 8080 is clean. Alternatively
set it in code:
builder.WebHost.UseUrls("http://0.0.0.0:8080");Kestrel is the production server. Out Plane terminates HTTPS at the edge, so you do not need a reverse proxy inside the container.
Deploy
Create an application from your repository. A multi stage Dockerfile is the most reliable
build:
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /app
COPY --from=build /app .
EXPOSE 8080
ENTRYPOINT ["dotnet", "YourApp.dll"]Replace YourApp.dll with your real assembly name, or the container crash loops with
"Could not find YourApp.dll".
Connect a Database
Create a managed PostgreSQL database and add the Npgsql EF Core
provider (dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL). Provide the
connection string as an environment variable. A double underscore maps to nested
configuration:
ConnectionStrings__DefaultConnection=Host=...;Database=...;Username=...;Password=...;SSL Mode=Require;Copy the .NET formatted string from the database's Connection panel, which already
includes SSL Mode=Require.
Run Migrations
Out Plane has no pre deploy hook. Run EF Core migrations once from the
browser terminal with dotnet ef database update, or apply them
at startup in Program.cs with db.Database.Migrate().
Environment Variables
| Variable | Notes |
|---|---|
ASPNETCORE_URLS | The binding, for example http://+:8080. |
ASPNETCORE_ENVIRONMENT | Set to Production. |
ConnectionStrings__DefaultConnection | Your database connection string. |