Thank you for reaching out. We understand the urgency of resolving the instability in your Azure Function App, given the critical role it plays in your B2B product release. Below are our insights and recommendations regarding your concerns:
- Understanding Resource Allocation You are correct that the Maximum instance count setting in the Azure portal controls the overall scaling of the Function App but does not directly affect the resources available to each function execution. Regarding the batchSize setting in
host.json
(underextensions => queues
): SettingbatchSize
to1
ensures that each function execution processes a single message at a time. In this case, the function execution will have access to the full memory allocated to the Function App (4 GB in your scenario). However, memory allocation still depends on the selected hosting plan. If you are using the Consumption Plan, function executions may share compute resources within the same instance. For dedicated memory allocation, the Premium Plan (e.g.,EP2
or higher) is recommended. - Azure Functions do not provide a direct equivalent to active replicas (as seen in Container Apps), but you can monitor scaling behavior through: 🔹 Azure Monitor & Application Insights
- Navigate to Azure Portal > Function App > Metrics and add:
- "Function Execution Count" – to monitor concurrent executions.
- "App Service Plan Instance Count" – to track instance scaling.
- Configuring newBatchThreshold The
newBatchThreshold
setting should always be less than batchSize to avoid processing inefficiencies.
Setting newBatchThreshold = 0
could lead to issues, as it may prevent the function from processing new batches unless a certain threshold is met.
It is recommended to set this value to a small number (e.g., 1 or 2) to allow for efficient batch processing while ensuring timely execution.
Recommendations for Stability
- Upgrade to the Premium Plan (EP2 or higher) for dedicated memory per function execution.
- Set
batchSize = 1
to maximize available memory per execution. - Monitor scaling with Azure Metrics, Kudu, and Azure CLI.
- Ensure
functionTimeout
is configured appropriately inhost.json
to support long-running executions. - Consider using Azure Durable Functions if processing time is extensive.