You might want to consider using the Auto Heal functionality - as described in https://www.serverlessnotes.com/docs/auto-restart-an-unhealthy-web-app
https://learn.microsoft.com/en-us/azure/app-service/monitor-instances-health-check?tabs=dotnet and
https://learn.microsoft.com/en-us/azure/app-service/monitor-instances-health-check?tabs=dotnet
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin