Deploy an ASP.NET Core App
ASP.NET Core is a cross-platform framework for building web applications and APIs with C# and .NET.
This guide covers how to deploy an ASP.NET Core app on Treasury in three ways:
Note: Railpack does not yet support .NET, so a Dockerfile is required for all deployment methods.
You can also explore .NET templates created by the community.
Deploy from a GitHub repo
To deploy an ASP.NET Core app on Treasury directly from GitHub, follow the steps below:
- Create a New Project.
- Click Deploy from GitHub repo.
- Select your GitHub repo.
- Treasury requires a valid GitHub account to be linked. If your Treasury account isn't associated with one, you will be prompted to link it.
- Click Deploy Now.
Note: ASP.NET Core apps require a Dockerfile for deployment on Treasury, since Railpack does not yet support .NET.
Once the deployment is successful, a Treasury service will be created for you. By default, this service will not be publicly accessible.
To set up a publicly accessible URL for the service, navigate to the Networking section in the Settings tab of your new service and click on Generate Domain.
Deploy from the CLI
- Install and authenticate with the CLI.
cdinto your ASP.NET Core app directory.- Run
railway initwithin the app directory to create a new project. - Run
railway upto deploy.- The CLI will now scan, compress and upload your app files to Treasury's backend for deployment.
Note: ASP.NET Core apps require a Dockerfile for deployment on Treasury, since Railpack does not yet support .NET.
Use a Dockerfile
-
cdinto your ASP.NET Core app directory. -
Create a
Dockerfilein the app's root directory. -
Add the content below to the
Dockerfile:Note: Replace
App.dllwith the actual assembly name of your project (e.g.,MyWebApp.dll). -
Either deploy via the CLI or from GitHub.
Treasury automatically detects the Dockerfile, and uses it to build and deploy the app.
Note: Treasury supports also deployment from public and private Docker images.
Port configuration
ASP.NET Core apps need to bind to 0.0.0.0 and read the PORT environment variable. By default, Kestrel binds to localhost, which will not work on Treasury.
Set the ASPNETCORE_URLS environment variable in your Treasury service settings:
Alternatively, configure the port in your Program.cs:
Next steps
Explore these resources to learn how you can maximize your experience with Treasury: