Hi
My Environment is Azure Web App using Linux and Docker (using the official asp net core 3.1 runtime container as base)
I'm using the newest (3.1) hosting and lifetime interfaces (IHostApplicationLifeTime), and i get the "ApplicationStarted" events BUT i miss every event regarding ApplicationStopping/ApplicationStopped.
I have found the following issue, that explains how this should be solved in IIS.
https://github.com/aspnet/AspNetCoreModule/issues/115
But i have not found any information about pure kestrel inside docker/linux and behind Azure Web App.
Any news that i have missed , any considerations how to do that ?
Thanks in advance
Werner
We'll need to look at what a "Stop" command on the portal actually does. If it does docker stop on the container it should be triggering the events properly.
hi
re-investigated on my side:
Suprise:
AI shows that in the last 24 hours i had 16 starts (that's true, CI/CD in place and a lot of improvements in the code)
AND IT SHOWS 2 STOPPS - yesterday (i can see STOPPING and STOPPED for 2 stopps)
But only yestertay (~10 restarts ago).
A explicite test of AzurePortal.Stop today does NOT show "Stopp".
btw: the most important requirement is seeing the Stopp/event for container stopps caused by CI/CD
(i'm using Azure Web App Linux Continuos Integration and a WebHook (from docker hub to Azure) to retrigger a container refreshs/restart!!
currently i'm not able to reproduce the two working "stop" events from yesterday....
Regards Werner
@WernerMairl can you provide a runnable sample that reproduces the issue in Azure App Service for Linux/Containers? I'm not entirely clear on the expected behavior and the behavior you're seeing. If you can provide a sample and let us know the exact output/behavior you'd expect, that would be very helpful.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.
ok, i hope i can do that in the next few days
Sample repo located in
https://github.com/WernerMairl/aspnetcore_issue_18259
important code is starting here:
I'm logging 3 different messages implemented on IHostApplicationLifetime
Expected behavior: all 3 (101,102,103) messages should be triggered and visible inside the logs
Unexpected behavior: messages for "stopp requested" and "stopped" (102,103) are missing!
Hosting this on Azure Web (Linux), the logging shows always only the first message (101) bot not the others.
Here my logging file that shows 2 starts but no shutdown.
https://gist.github.com/WernerMairl/1345c01ef382f964b8aa669f62e2f3e4
line 2 and 3 shows the first start (message 101)
line 11 and 12 shows the second start.
App hosted on Azure here (App Service Plan F1)
docker container available on docker hub
Hrm. When I use docker stop locally it does work:
Issue Sample App
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
info: Sample.Web.Startup[101]
Application started
Application is shutting down... *** I ran docker stop [container ID] here**
info: Sample.Web.Startup[102]
Application stop requested
info: Sample.Web.Startup[103]
Application stopped
It seems like maybe that's not how Azure Web Apps for Linux is shutting things down. We may have to engage that team and see how they're doing things. It's probably the issue is on their end given my test results but we'll see what we can figure out.
It's happening the same to me.
ApplicationStopped and ApplicationStopping is not firing on app service on linux but ApplicationStarted does.
Any update?
I think this might be related? We are trying to gracefully stop our azure app service (linux container) by calling StopApplication but Azure still shows the app service as running and page returns "Application Error" 503 error instead of the 403 "This web app is stopped" that it normally displays when an app is stopped.
IHostApplicationLifetime appLifeTime = _serviceProvider.GetRequiredService<IHostApplicationLifetime>();
appLifeTime.StopApplication();
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.
This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!