- Published on
Host C# apps for free!
How to host .NET Core applications for free?
Do you ever fancy the Javascript trend where everything is so simple? You can deploy a node.js app almost instantly with platforms like Vercel and have CI/CD come along without any configuration.
Well i am here to lift you up because there is a way to deploy a .NET Core application the same way. And the best part? You can host it for free! (As long you don't make money out of it).
It's a perfect way to showcase your apps, make POCs and try new things without paying a dime.
Let's dive in and let me show you how.
I want to clarify that i am not sponsored by Heroku or Vercel (sadly)..
So what is Heroku? π€
Heroku is a cloud service platform whose popularity has grown in recent years. Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly. Heroku is so easy to use that itβs a top choice for many development projects.
In other words it is a PaaS solution that helps developers deploy apps quickly. It does so by connecting to the git provider you use and deploying the application each time you sync the main branch.
The bad and the good news ππ
The bad news is that heroku (at the time of writing) only supports the following languages:
- Node.js
- Ruby
- Python
- Java
- PHP
- Go
- Scala
- Clojure
But don't worry! The good news is that a third-party buildpack exist that can provide what we need. To be able to build C# code!
Buildpacks automate the build processes for your preferred languages and frameworks.
Step by step process π
So let me show you how you would go about doing that for a C# app. In this tutorial i will host a simple Asp.NET Core Web API, but keep in mind that you can do the same for any .NET Core app.
The steps are:
- Create your .NET app.
- Add it to a GitHub repository. In my case i created a repo named "TestHeroku"
- Create an account in Heroku.
After logging in you should see the following screen:
- Click on "Create new project".
- Select how you want to name your app and the closest location to you.
In my case "martins-app-name" (naming done right π) and the Europe region.
- Click on "Create app".
- In the deployment method section, select "Github".
- In the Connect to github section, type the name of your repository and click search. Click on connect after it finds your repo.
- Click on "Enable automatic deploys". This is the continuous delivery feature. Meaning that each time you do a 'git sync' the app will be automatically redeployed with the latest changes.
- Click on "Add buildpack" in the buildpacks section under the Settings tab.
- Go back to the deploy tab.
- In the manual deploy section click on "Deploy Branch.
- You are done! You should see the application building in the "Activity" tab. So wait for a couple minutes and your app will be up and running!
Lets test the app π₯
We are now ready! We can send an http GET request and get a response by opening a postman client and typing the url of the app and the endpoint of our API. You can find the base URL in the settings in the domain section.
What now? π₯
Now that we are up and running, there is a ton of possibilities ahead! We can add a purchased domain. We can create other branches to steadily add new features to our app. Each time we want to deploy we only have to sync the branch to our main branch!