QuestionQ185

VerifiedConnect to and consume Azure services and third-party services

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 this exception. What should you do?

Explanation

An Azure Storage queue trigger retrieves and processes queue messages concurrently. The batchSize setting in host.json controls the number of messages processed in parallel, so decreasing it reduces concurrent Azure Function invocations and their simultaneous Azure SQL Database connection usage. This avoids exhausting the SQL connection pool.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!