Question

How to set up .NET 6 Web API backend with a database

I’m trying to deploy an online application with a .NET 6 Web API backend app with a database on App Platform. There are several questions/problems that I’m having at the moment and after trying to research and look for an answer I’m still unable to solve them.

  • I have successfully pushed my .NET 6 Web API GitHub repository into App Platform with a Dockerfile and tried to build it. The build was successful and complete but then I get -

Ibrahim Sinan’s deployment failed during deploy phase

Deploy Error: Health Checks

Since I’m new to deployment in general, I have also not configured any Environment variables and I could not find any information or tutorials about what they need to be for .NET Web API applications, or how to set up .NET in App platform

  • In addition to the backend application, I also have a database with it. I have created and attached a database in the set up process in App Platform and I need to migrate my database to it. Can I make this migration to a Dev Database or do I need a Production-Ready database to be able to migrate.

  • Do I need to containerize the database in order to make it work with the containerized backend or is this not necessary?

Thank you for your time!

Best, Ibrahim


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 6, 2022

Hi there,

The Health check might be failing if you’ve not configured your database yet, as if your .NET is trying to connect to your database and it is not there it is likely to be crashing. Do you see any errors in the logs?

Regarding the database, I would not recommend deploying the database itself on the App Platform directly, as the storage of the App Platform is ephemeral, meaning that after each deployment anything that was stored on the local storage will be lost:

https://docs.digitalocean.com/products/app-platform/how-to/store-data/

If you need to use a SQL server, then I would recommend installing it on a Droplet and using it as an external database.

Alternatively, if you could switch to a Postgres database, I would recommend the managed Postgres instances:

https://docs.digitalocean.com/products/app-platform/how-to/manage-databases/

Hope that this helps!

Best,

Bobby