CI/CD & Hosting
I am using Microsoft Azure to host my applications. Which is be the default choice in the .Net space.
The code base comes with a github workflow to automatically deploy to production on any push to master.
I wont say that I have weighed it against many alternatives. It just works.
To set this app you need 3-4 services.
5 Minute Hosting on Railway
I checked out some easier hosting options and found https://railway.app (opens in a new tab)
Railway is a really easy point and click host where you can link your github repository and create a postgres database within a couple of minutes.
It's free to start. No credit card required. I also think everything up to 5$ a month is free.
There is a Dockerfile at the root of the solution that will automatically be picked up by railway.
Railway will automatically redeploy your app, whenever you push changes to the github repository.
How To
- Link your github repository (It will automatically build, deploy and start)
- Go to Settings => Networking => Public Networking and add a free ssl domain
- Right click to create a postgres database
- Adjust the "ConnectionString" environment variable (in your appsettings or wherever) with the values from the "Variables" tab.
Youre gonna need hostname, port, username, password and database.
I don't know about the cost this is gonna incurr yet. But it is marketed as the "easy, cheap, fast, getting started hosting option for side projects".
I've moved 2 of my low traffic apps over and will monitor the situation. I hope its less than 5$.
It looks like a really good solution to just get something out there quickly, before you move onto the heavier azure / aws services, should your app take off.
Azure Services
-
App Service - Web App (opens in a new tab) - This is hosting the API. It itself doesnt cost anything.
-
Application Insights (opens in a new tab) - is automatically set up with your App Service. This is where your structured logs are getting stored.
-
App Service Plan (opens in a new tab) - This is essentially how you pay for your App Service. App Services run on compute from App Service Plans.
Start at 0€ and go all the way up. I'm running all my apps on a single 80€/month Premium (P1v2) linux plan. -
Azure Database for PostgreSQL flexible server (opens in a new tab) - The database you choose.
I use postgres. Their cheapest plan is around 20€/month, which is a little hefty.
The MSSQL versions are starting around 5 bucks. -
Blob Storage Account (opens in a new tab) - This is where you store files. Azures equivalent of S3. Pricing depends on usage. Unless you pop off, probably 0-1€/month.
External Services
To fully get started you also need to set up your accounts with the external service providers.
- Azure (opens in a new tab) - Cloud provider to make all of the above work in the first place.
- Stripe (opens in a new tab) - Payment provider. You need an account and a product. The documentation is pretty good and they have an extensive test environment. They take a percentage of your sales.
- Sendgrid (opens in a new tab) - Email provider. Sends out your emails, tells you which didnt get received, which got opened etc. Free for 100 Emails a day.
Final Thoughts
It sounds complicated at first, but its really just 3 services that you can't get around with any real application, hosted anywhere.
Your api. Your database. Your storage.
Azure and github are also pretty well integrated.
If you set up a web app, it will automatically ask for your github account, link the accounts, drop a secret into your account, set up a github workflow.
Again this is just my set up and completely optional. You can run .net anywhere, you can host your database and files anywhere.
I will look into setting up a full docker image to maybe make deployment more flexible, easier and cheaper.
I will also look into setting all of these services up in a template so you (and me) dont have to do click ops anymore.