My function recently is taking longer to complete. Then when I look into the Application insights I found multiple 'Running' instances as below:
Then I use my postman to query the status by InstanceId, the GET return status completed:
In this case, which one is the source of true? Also would like to know how can I properly terminate the long running job at the backend? Thanks
In Postman when you see completed, it means the function has been called by the http request and it has send an response in return to it. It does not mean that the functions execution is completed and their are many reasons that the function can still run.
But when you see a Running in Application insights it means the instance of functions is still in running as their might be many reasons such as Delay, some unfinished running tasks or may be the function is waiting for some action to be completed.
For ways to find out why it is running you can break points where it is taking time, or maybe sometimes the function might have been corrupted.
You can also set a timeout and check if your function has completed within that timeout or not. Another reason is that Sometimes Application Insights takes 5 to 10 minutes to reflect back the actual status of functions, but it does not mean that the function is still running. If you still feel there is some issue i would suggest you to raise a support request.