Out Plane LogoOut Plane

.NET

Step-by-step guide to deploy an ASP.NET Core application on Out Plane

This guide walks you through deploying an ASP.NET Core Web API on Out Plane using Git-driven deployment with a Dockerfile.

Prerequisites

  • An Out Plane account
  • A GitHub account
  • .NET 8 SDK installed on your machine
  • Git installed on your machine

Create the .NET App

Create a new ASP.NET Core Web API project:

dotnet new webapi -n MyWebApi
cd MyWebApi

This creates a minimal API with a sample weather endpoint.

Configure for Production

Open Program.cs and update it to read the port from environment variables:

var builder = WebApplication.CreateBuilder(args);

// Configure port from environment variable
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
builder.WebHost.UseUrls($"http://0.0.0.0:{port}");

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.MapGet("/", () => new { message = "Hello from Out Plane" });

app.MapGet("/health", () => Results.Ok("OK"));

app.MapGet("/weatherforecast", () =>
{
    var forecast = Enumerable.Range(1, 5).Select(index =>
        new WeatherForecast
        (
            DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
            Random.Shared.Next(-20, 55),
            summaries[Random.Shared.Next(summaries.Length)]
        ))
        .ToArray();
    return forecast;
});

app.Run();

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

var summaries = new[]
{
    "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

Create the Dockerfile

Create a file called Dockerfile in your project root:

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app

COPY --from=build /app/publish .

EXPOSE 8080

ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production

ENTRYPOINT ["dotnet", "MyWebApi.dll"]

Replace MyWebApi.dll with your project's assembly name if different.

Create a .dockerignore file:

bin
obj
.git
.vs
*.user
*.md
.DS_Store

Test Locally

Run the application:

dotnet run

Open http://localhost:5000 (or the port shown in the console) in your browser.

To test the production build:

dotnet publish -c Release
dotnet ./bin/Release/net8.0/publish/MyWebApi.dll

Push to GitHub

Initialize a Git repository and push to GitHub:

git init
git add .
git commit -m "Initial commit"
git remote add origin [email protected]:YOUR_USERNAME/MyWebApi.git
git branch -M main
git push -u origin main

Replace YOUR_USERNAME with your GitHub username.

Deploy on Out Plane

Step 1: Install GitHub App

  1. Go to console.outplane.com
  2. Navigate to Applications from the sidebar
  3. Click Deploy Application
  4. If prompted, click Install GitHub App
  5. Select which repositories Out Plane can access
  6. Click Install and you'll be redirected back

Step 2: Select Repository

  1. Find your repository in the list
  2. Click to select it
  3. Choose the branch to deploy (default: main)
  4. Set Root Directory to /

Step 3: Configure Build

SettingValue
Build MethodSelect Dockerfile
Application NameEnter a unique name (e.g., my-web-api)
Port8080

Step 4: Select Resources

InstancevCPURAMRecommended For
op-4611 GBSmall APIs
op-8222 GBProduction (recommended)
op-9444 GBHigh traffic

Step 5: Configure Scaling

  • Min Scale: Set to 1 for always-on
  • Max Scale: Set based on expected traffic

Step 6: Environment Variables (Optional)

Click Add Variable to add environment variables:

KeyValue
ASPNETCORE_ENVIRONMENTProduction
ConnectionStrings__DefaultConnectionYour database connection string

Step 7: Deploy

  1. Review your configuration
  2. Click Create Application
  3. Wait for the build to complete (typically 2-4 minutes)

Step 8: Access Your App

Once the deployment status shows Ready:

  1. Go to the application Overview tab
  2. Find your domain: my-web-api.outplane.app
  3. Click to open your live application

Adding Entity Framework Core

Step 1: Install Packages

dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
dotnet add package Microsoft.EntityFrameworkCore.Design

Step 2: Create DbContext

using Microsoft.EntityFrameworkCore;

public class AppDbContext : DbContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

    public DbSet<TodoItem> TodoItems { get; set; }
}

public class TodoItem
{
    public int Id { get; set; }
    public string Title { get; set; } = "";
    public bool IsComplete { get; set; }
}

Step 3: Configure in Program.cs

var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")
    ?? builder.Configuration.GetConnectionString("DefaultConnection");

builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseNpgsql(connectionString));

Step 4: Create Database on Out Plane

  1. Go to Databases in the sidebar
  2. Click Create Database
  3. Configure and create the database
  4. Copy the connection string
  5. Add it as DATABASE_URL in your app's environment variables

Automatic Deployments

Push to your branch to trigger automatic deployments:

git add .
git commit -m "Add new feature"
git push origin main

Next Steps