AZ-204 – Question 93

0
413
​You are developing an Azure function that connects to an Azure SQL Database instance. The function is triggered by an Azure Storage queue.
You receive reports of numerous System.InvalidOperationExceptions with the following message:
`Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.`

You need to prevent the exception.What should you do?

A. In the host.json file, decrease the value of the batchSize option
B. Convert the trigger to Azure Event Hub
C. Convert the Azure Function to the Premium plan
D. In the function.json file, change the value of the type option to queueScaling
Correct Answer: A 

The error shown is a SQL Server error not an Azure functions error.

https://forums.asp.net/t/2004198.aspx?Timeout+expired+The+timeout+period+elapsed+prior+to+obtaining+a+connection+from+the+pool+This+may+have+occurred+because+all+pooled+connections+were+in+use+and+max+pool+size+was+reached+
The actual issue appears to be that you have too many simultaneous functions running, the solution is to limit the batch size (# functions that can run in parallel)

https://social.msdn.microsoft.com/Forums/azure/en-US/a2955297-1c14-45f2-b799-6346b340519a/how-does-batchsize-works-in-hostjson?forum=AzureFunctions

We have to consider we are speaking about Azure Function with Azure Storage Queue Trigger. This is a case where execution could happens in parallel based on the queue batchSize property

(see https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue).
I think this is the batchSize property referred in the question (and not that in the functions aggregator. That’s another thing).

Besides, we have to consider the origin of the error message: Azure Sql Database!! So upgrading the plan the problem could only get worse thing.