Azure app service getting restarted abruptly

Ankush Kulkarni 20 Reputation points
2025-05-07T11:06:56.98+00:00

I have an Azure app service with app service plan P1mv3 : 1.

We have deployed the .net 8 web api project which has a background service as well.

Background service does below things -

  1. Get the journal data from one of our on-premises endpoint for 1700 journals.
  2. Generate the embeddings for all the journal names in the batches of 100 with a delay of 5 seconds after each batch using Azure open AI. We use these embeddings for vector search in cosmos db to better search by journal title.
  3. Delete all the records from existing cosmos DB container in the batches of 100 with a delay of 5 seconds after each batch. We do this as we need to insert the fresh data each week.
  4. Insert all the records with embeddings generated in step-2 in cosmos DB container in the batches of 100 with a delay of 10 seconds after each batch.

The problem is once we deploy this to app service after verifying that everything works fine on local system, the app service just generates 800/1000 out of 1700 embeddings and just restarts. We can see the logs as "Hosting environment: Production", "Content root path: c:\home\site\wwwroot" etc after our custom logs depicting the progress to generate the embeddings. e.g. Progress: 1000/1700 items embedding results generated.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,961 questions
{count} votes

Accepted answer
  1. Pravallika Kothaveeranna Gari 955 Reputation points Microsoft External Staff Moderator
    2025-05-14T11:46:41.0733333+00:00

    Hi Ankush Kulkarni,

    By default, the HTTP request timeout for Azure App Service is 230 seconds. This timeout applies only to synchronous HTTP requests and does not affect background services** such as IHostedService or BackgroundService, which operate independently of HTTP request lifetimes.

    In your case, since the embedding generation runs in a background service, this timeout does not apply.

    Monitor application and web server logs:

    • Navigate to App Service=>App Service Logs.
    • Enable Application Logging and Web Server Logging.

    image

    • Check the logs in Log Stream to find out the root cause of the abrupt restarts.

    If a process consumes more than 100 MB private bytes of memory then a memory dump will be created.

    This does not directly cause a restart, but it can trigger a memory dump, and it could be part of an auto-heal rule that restarts the app if configured to do so.

    • 100 MB is quite low for a .NET app performing embedding generation.
    • As your App Service Plan (P1mv3) has 16 GB RAM, you can increase the private bytes threshold.

    Try updating Auto-Heal Rule:

    • Go to App Service => Diagnose and Solve Problems => Auto-Heal => Memory limit.
    • Edit the rule which monitors private bytes.
    • Increase the threshold to at least 1 GB or higher based on your requirement.

    image

    • Alternatively, remove the memory-based auto-heal trigger completely if not needed.

    Enable Proactive Scaling Monitoring:

    • Monitor actual memory and CPU in App Service => Metrics.
    • Set up alerts if memory usage stays near the limit to anticipate issues.

    image

    Hope it helps!


    Please do not forget to click "Accept the answer” and Yes wherever the information provided helps you, this can be beneficial to other community members.

    User's image

    If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ankush Kulkarni 20 Reputation points
    2025-05-12T09:44:55.3666667+00:00

    Hi All,

    Thanks for adding comments.

    I have checked in my app service following-

    1. Always on is enabled
    2. Auto heal settings are on and like below.User's image
    3. No error messages or logs are present when the app service restarts.
    4. Background job takes around 10-15 minutes to finish everything.
    5. The application insight is enabled on the app service. It does not show any errors when the app service restarts.
    6. I am not sure where we set the http request timeout in app service? Do we set the same in auto heal settings?

    I observed my current auto heal settings are set with respect to memory limit. If a process consumes more than 100 MB private bytes of memory then a memory dump will be created. Is this causing a sudden restart as current process might be consuming more than 100 MB of memory? P1mV3 has 2 cores 16 GB memory.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.