Shumachine
Shumachine

Reputation: 61

After migration from .NET core 2.2 to .NET 5 the application won't start after deploying to azure app service - startup timeout

I am having the following problem. A while ago I migrated my project from .net core 2.2 to .net 5. Migration itself was no problem, locally everything worked almost out of the box. But then I was facing problems deploying the app into an azure app service. The app wouldn't start up. I was getting start up timeouts. After a while I solved the problem by switching the hosting model to outOfProcess

<PropertyGroup>
  <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

Because of lack of time to thoroughly test the application, I had to stick with .net 2.2 until now.

Now that I migrated again, I am facing the same issue. Locally everything works just fine, but after deploying to the app service, the application won't start. But the hostingModel doesn't solve it this time.

I tried linux and windows app service, and I tried to deploy via our azure devops pipes as well as manually from VS. I tried to deploy into an existing app service, I tried to deploy into a new app service, created during the deployment process. None of it solves it.

When i look at the log stream, I see the following:

2022-02-10T09:13:55.360Z ERROR - Container webapp... for site t2bwebappdev did not start within expected time limit. Elapsed time = 230.2593377 sec 2022-02-10T09:13:55.368Z ERROR - Container webapp... didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

So I tried to solve this via PORTS and WEBSITES_PORT settings - but non of it seems to get it up and runnig.

Thanks in advance for any hints on how to solve this.

Update:

While I was playing around with the logs, I saw that the app was listening on port 5000. Seems with the Net5 upgrade the launchsettings.json is being ignored.

Then I just dockerized it from VS 2019, and in that container I can also not reach the app. So after all this, could it just be a port issue?

Upvotes: 1

Views: 579

Answers (1)

Niyazi Babayev
Niyazi Babayev

Reputation: 142

Try adding this line in your Program.cs class:

Program.cs

And make sure you expose ports in Dockerfile:

Dockerfile

NOTE:

Everything depends on which port was exposed in Dockerfile. Port that you have exposed should match with the port you will pass to UseUrls as an argument. Also, consider either http/https in accordance with the existence of the certificate.

I hope my answer was useful and helpful!

Upvotes: 1

Related Questions