An Azure Function triggered by a Storage queue connects to an Azure SQL Database and is throwing System.InvalidOperationException: timeout acquiring connection from the pool (max pool size reached). What should you change to prevent this exception?
Choose an answer
Tap an option to check your answer.
Correct answer: In host.json, reduce the batchSize value.
Why this is the answer
The System.InvalidOperationException: timeout acquiring connection from the pool (max pool size reached) indicates that the function is opening too many connections to the SQL database concurrently, exhausting the connection pool. Reducing the batchSize in host.json for the Storage queue trigger will cause the function to process fewer queue messages in a single invocation. This reduces the number of concurrent database operations, allowing connections to be released and reused more efficiently, thus preventing the connection pool from being exhausted. Converting to Event Hubs or switching to a Premium plan would not directly address the connection pooling issue, as the problem lies in the function's resource consumption pattern, not the trigger type or hosting plan. There is no queueScaling type in function.json.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed