Azure Functions silently stops during execution

Johan Tokarskij 0 Reputation points
2025-03-01T02:05:58.3966667+00:00

I have an Azure function running on Consumption Flex that was silently stoped three times during the last two days. It runs using python v2.

The function does't show in the invocations at all, so it looks like it never got triggered. But I know that it has started and worked for around 2 mins (as I see the results of it) and then just silently stops. When I open "Disagnose and solve problems" -> "Availability and Performance" I see this:

function_run

But I don't know if this can help me because the functions stops just after a couple of minutes.

In the Logs -> Traces, I see that it just stops emitting the traces in the middle of the process:

unnamed

My fucntion is request heavy and uses requests.Session, but every call has a timeout defined. When I run the function locally it completes without any problem.

Also, I use try-catch block inside the main funtion, which would make me think that if an exception would occure, it would trigger the exception block. I don't use async. When I use Live metrics during the function execution I see quite a few servers being dedicated (can be 6-8), while the cpu and memory stays at extremely low levels.

I have been running the same code in Functions for more than 3 months without any issue, but as I mentinoed before I have had three silent stops during the short period.

Can anyone please help me investigate the issue?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,589 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pavan Pesala 5 Reputation points Microsoft External Staff
    2025-03-14T10:13:56.7833333+00:00

    Hi @Johan Tokarskij,

    You can enable verbose logging in Application Insights by modifying your host.json file like this:

    
    {
    
      "logging": {
    
        "applicationInsights": {
    
          "samplingSettings": {
    
            "isEnabled": false
    
          },
    
          "logLevel": {
    
            "Function": "Trace",
    
            "Host": "Information"
    
          }
    
        }
    
      }
    
    }
    
    

    This will help track all interactions and might provide you with more detailed logs on whether specific requests, errors, or scaling events are related to the issue you're facing.

    Regarding the scaling limit, I should clarify that the functionAppScaleLimit setting doesn’t apply to the Consumption Flex plan. This feature only works with Premium or App Service plans, so you won’t be able to use it to limit the number of instances in the Consumption Flex plan. Since you're on the Consumption Flex plan, you won’t be able to restrict scaling directly with this setting.

    Since Always On is also not available on the Consumption Flex plan, you can try a workaround by implementing a warm-up strategy. You can use an Azure Timer Trigger to send regular, small requests to your function every few minutes, keeping it warm and reducing the chances of it being recycled during idle times. A simple example would look like this:

    
    def  warm_up_trigger():
    
        log.info(f"Function warmed up at {datetime.datetime.now()}")
    
    

    I hope you find this information useful!

    If this answer was helpful, please click Accept and leave a thumbs up by clicking Yes/Like.

    If you require assistance with a technical support issue, please post a new thread so we can assist you on providing a resolution.If you have any further questions, please click Comment .


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.