DEV Community

Cover image for Deploying .NET Core to Heroku

Deploying .NET Core to Heroku

Andrew Robilliard on August 31, 2020

I've always loved coding in C#. Equally, I love using Heroku to host personal projects - they have a nice UI, and a free tier! However, there are ...
Collapse
 
m_kunc profile image
Martin Kunc

Thanks Andrew, this was exactly the problem I run into.
I tried to use EXPOSE $PORT and ENV ASPNETCORE_URLS=http://*:$PORT
but for some strange reason only passing ENV var on command line helped.
Really helpfull post, thank you !

Collapse
 
olcay profile image
Olcay Bayram

Great job! If you do not want to use Docker, there is also a third party buildpack for .NET Core; github.com/jincod/dotnetcore-build...

Collapse
 
nomediganlucho profile image
Luis Gabriel Fabres

Hi, I followed all the steps in your tutorial, but after doing the release, when entering the page of the app that I published, I get an error that says:
Error: Missing required flag:
-a, --app APP app to run command against.

My application is called miappmvc and the commands that I enter in the heroku CLI are:
heroku container: push -a miappmvc web
heroku container: release -a miappmvc web

there it says that I am missing a flag. Do you know what flag it refers to?

Collapse
 
alrobilliard profile image
Andrew Robilliard

Hi Luis,

It looks like you're nearly there! The error you're getting is just referring to the app flag '-a', which you're already including.

I suspect the issue is with the commands you're running. It should be:
heroku container:push -a miappmvc web
heroku container:release -a miappmvc web

(no space after "container:")

Collapse
 
kudostoy0u profile image
Kudos Beluga

Lifesaver. Thank you so much! :D
Here's what I got at the end:
herokunett.herokuapp.com/

Collapse
 
alrobilliard profile image
Andrew Robilliard

Nice job getting it live! Thanks for sharing 😁

Collapse
 
christianaugustyn profile image
Christian Augustyn

I was scouting for options for Heroku and .Net Core and this is perfect! I haven't tried out the tutorial but i really appreciate the time and effort you took to document the steps. Will it work if I'm trying to deploy an API as well?

Collapse
 
ravehunter05 profile image
Francisco Paul Sotelo Rocha

thank you so much, that was very usefull

Collapse
 
matteodellirocioli profile image
MatteoDelliRocioli

Man you are a legend!
Thank you so much for this article! I hope you are doing well 😁

Collapse
 
boreal_root profile image
Boreal ☄

Andrew, thanks.

It worked!

Collapse
 
ajimerasrinivas profile image
Srinivas Ajimera

This blog was really great, never seen a great blog like this before. I think I’m going to share this with my friends.

espirittech.com/dot-net-applicatio...

Collapse
 
moseskereya profile image
Moses

hello!! is it possible deploy asp.net core website with data in the database to heroku?

Collapse
 
zangassis profile image
Assis Zang

You saved my life, thank you so much 😀👏😊🦄

Collapse
 
shricharan29 profile image
shricharan29

will it also work for dotnet 4.7

Collapse
 
lukerobinett profile image
Luke Robinett

Thank you. I was intimidated by the idea of containers but this doesn't sound difficult at all. Question: what if we need a SQL database with our app?

Collapse
 
baodoanuit profile image
Doan Le Ngoc Bao

Thanks Andrew, it worked.