Build, deploy and host your .Net core API for Free with Utopiops

Sam - Jan 25 '22 - - Dev Community

As a software developer or a software development team, the most important thing for you is building quality software, shipping it and getting feedback from your customers.

Utopiops (utopiops.com) is a new player in town that aims to solve the problem uniquely by giving you a complete ecosystem that supports you entire platform from build, deployment and hosting your applications to monitoring the platform, incident reports and integrations with issue tracking systems.

Utopiops also supports Fully-managed and Managed applications. The Fully-managed applications are hosted on Utopiops cloud platform, while Managed applications are hosted on your own cloud accounts.

In his post I show you how to host your applications using Fully-managed applications on Utopiops for free.

To do so, I have implemented a simple Web API with .Net Core along with a typical Dockerfile.

You can create the project like this:

dotnet new webapi --no-https
Enter fullscreen mode Exit fullscreen mode

I've been using VS Code so I used the C# extension to add the Dockerfile effortlessly.

You can follow the steps in this tutorial which perfectly explains how to set up your project to run inside a Docker container.

I also updated launchSettings.json and modified the applicationUrl so the API listens on port 5000.

When you create the new project with the command I mentioned earlier, it adds a dummy controller which I keep as it serves the purpose. The only thing you have to add is a health-check controller. This controller should determine if your application is healthy or not. If the status code of the response to the GET request to this endpoint is in the range 200-299 it's considered as healthy, otherwise your application's container will be automatically replace by a new one.

This is the code I added in HealthController.cs:

using Microsoft.AspNetCore.Mvc;

namespace netcore_api_deployed_on_utopiops.Controllers;

[ApiController]
[Route("/health")]
public class HealthController : ControllerBase
{

    [HttpGet]
    public String Get()
    {
        return "Healthy";
    }
}
Enter fullscreen mode Exit fullscreen mode

Screen Shot 2022-01-25 at 9.16.41 pm.png

You can find all these files in the repository here.

Before we begin the deployment you need to create an account on Utopiops if you already haven't done that before, by registering and verifying your email.

Now we create a dockerized application

Screen Shot 2022-01-24 at 12.56.53 pm.png

Then we choose the repository we have stored our code:

Screen Shot 2022-01-24 at 1.00.08 pm.png

I'm using Github for this example, but you can also use Gitlab and Bitbucket too.

Finally just git your application a name, set the git branch, the port your application is listening on, and an endpoint that can be used as health check. Remember that health-check path is just any endpoint that returns a 2xx response to an unauthorized HTTP GET request.

You can also set the environment variables if you like.

Screen Shot 2022-01-25 at 10.47.26 pm.png

Right away the built-in CICD on Utopiops is set up and starts building and deploying your application.

Screen Shot 2022-01-25 at 10.49.10 pm.png

You can see the build logs live as they happen:

And in a just few seconds your application is available (for this example it took 3 seconds to be precise)

Screen Shot 2022-01-25 at 10.49.21 pm.png

Notice that by default HTTPS is provided for you application, just the certificate takes a few minutes to be effective, but guess what! We're working on it to reduce that to few seconds as well.

Screen Shot 2022-01-25 at 10.56.44 pm.png

Worth mentioning, any time you make a change to your target branch, the new version of your application is built and deployed right away.


Final note

We're a very young startup with huge goals in our mind. You can be part of the first users who get to know about our features and our journey.

Please join our family by joining our discord channel, and following us on Twitter, and using our service. We have a generous hobby plan!

Please leave a comment if you have any questions or even want to see a private demo!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .