DEV Community

Ali Mahdavi
Ali Mahdavi

Posted on

Deploying ASP.NET Core Apps on the Flux Network Using Deploy With Git

ASP.NET Core is a popular framework for building modern, cross-platform web applications and APIs. Deploying these apps on the decentralized Flux Network is simple and efficient with the Deploy With Git feature. This guide explains how to deploy a minimal "Hello World" ASP.NET Core application directly from a Git repository. Flux automatically detects the project, installs the required .NET SDK, builds the application, and runs it across its global network of nodes.

No Dockerfiles or complex setup are needed. Just push your code to GitHub, and Flux handles the entire process.

How Flux Handles ASP.NET Core Deployment

Flux makes .NET deployments straightforward:

  1. It scans for .csproj files to identify .NET projects.
  2. It reads the TargetFramework from the .csproj file (this example uses .NET 8.0 LTS).
  3. It installs the matching .NET SDK.
  4. It runs dotnet restore to fetch dependencies.
  5. It executes dotnet publish -c Release -o ./publish to compile the app.
  6. It starts the application with the specified runtime command.

The ASP.NET Core app binds to 0.0.0.0:$PORT using the ASPNETCORE_URLS environment variable, which Flux sets automatically. The app then becomes available on the Flux network.

Important note: You must set the RUN_COMMAND environment variable to tell Flux which DLL to execute after publishing.

Prerequisites

Before starting, make sure you have:

  • A public GitHub repository (or a private repository with a GitHub personal access token).
  • A FluxCloud account.
  • Basic knowledge of Git and ASP.NET Core.

Step-by-Step Deployment

1. Prepare and Push Your Project to GitHub

Push your ASP.NET Core project to GitHub. Use a public repository for the easiest setup, or provide a personal access token for private repositories.

2. Register the Application on FluxCloud

  1. Go to the FluxCloud dashboard and select Deploy with Git.
  2. Log in or create a new FluxCloud account.
  3. Choose your preferred plan and click Start Deploying.
  4. Enter the following details:
    • Repository URL
    • Branch name
    • Path to the project (for example, deploy-aspnet-core/ if inside a monorepo)
    • GitHub personal access token (only required for private repositories)
  5. Click Continue and complete the configuration form.
  6. Review the settings and click Register.

Flux will build and deploy your application across multiple nodes. When finished, your app will be live at:

https://YOUR-APP-NAME.app.runonflux.com

Configuration Settings

Configure these fields during the registration process.

Basic Information

  • Application Name: Use 3 to 32 characters consisting of lowercase letters, numbers, and hyphens only.
  • Contact Email: Provide an email for deployment notifications and alerts.

Application Port

Set the Application Port to 8080. This must match the port your ASP.NET Core application listens on.

Custom Domain (Optional)

You may add your own custom domain. After deployment, update your DNS records to point to Flux.

Advanced Options

  • Auto-Update Polling Interval: Controls how often Flux checks for repository updates. The default is 24 hours. For faster updates, use GitHub webhooks.
  • Enterprise App: Enable this option for extra security. It encrypts your app specification and environment variables and limits deployment to verified ArcaneOS nodes.

Environment Variables

Set the following variables as needed:

Variable Name Description Required Default Value
RUN_COMMAND The command to start the app Yes (none)
PORT Port the server listens on No 8080
DOTNET_VERSION .NET SDK version to use No Detected from csproj (8.0)
BUILD_COMMAND Custom build command No dotnet publish -c Release -o ./publish
WEBHOOK_SECRET Secret for GitHub webhook authentication No (none)

Critical requirement: Set RUN_COMMAND to dotnet deploy-aspnet-core.dll. This tells Flux the correct entry point for your published application.

Enabling Automatic CI/CD with GitHub Webhooks

To redeploy automatically on every code push:

  1. After your app is running, copy the webhook URL from the Flux dashboard (format: https://YOUR-APP-NAME-9001.app.runonflux.io/webhook).
  2. In your GitHub repository, go to Settings > Webhooks > Add webhook.
  3. Set the following:
    • Payload URL: Paste the Flux webhook URL.
    • Content type: Select application/json.
    • Secret: Use the same value as your WEBHOOK_SECRET environment variable.
    • Events: Choose "Just the push event".
  4. Save the webhook.

Every git push to the selected branch will now trigger an automatic redeployment, usually within about 2 minutes. Flux rolls back automatically if the build fails.

Resources

This method allows you to deploy ASP.NET Core applications quickly and reliably on the Flux Network. With only a Git repository, your app becomes globally distributed and highly available in minutes. Fork the example repository and try deploying your own ASP.NET Core app today.

Top comments (0)