Is there a way to programmatically get the number of running instances for a Function App?

Elizabeta Ilieva 1 Reputation point
2022-01-12T12:21:25.94+00:00

I need to get the number of concurrent instances running for a Function App in code.
Is there a way to achieve this?
I'm using NodeJS

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

1 answer

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,051 Reputation points
    2022-01-14T19:39:45.937+00:00

    Jeremy's option to query App Insights logs will work, but there is a delay- this might be fine for your purposes.

    There are a couple endpoints in the Azure REST API that can give you useful info:

    If you are using a plan that scales at the App Service level the it's GET method will return info on the number of instances:
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}?api-version=2021-02-01

    Under the Web Apps API, you can get instance info for your function app currently even on consumption plan:
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances?api-version=2021-02-01

    If you are looking for the current number of processes (since there can be more than one per instance), you can take the IDs from the previous query to get the processes.
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances/{instanceId}/processes?api-version=2021-02-01

    1 person found this answer helpful.
    0 comments No comments

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.