Azure SQL Connection Delay on App Service Environment

Asiful Nobel 196 Reputation points
2022-01-26T06:46:52.45+00:00

I have a .NET Core Azure Functions App hosted on an App Service plan inside App Service Environment (ASE v2). The plan is on isolated I2 pricing tier. The Functions app has Always On setting turned on. For some reason, the app is having slowness issues connecting to Azure SQL database. The database is running on same region as the Functions app and has Business Critical pricing tier.

I am seeing in Application Insights that API calls are taking seconds to finish because the codepath is busy waiting to get an SQL connection. The actual database operations finish within milliseconds.

I have ran the app locally with database connection strings set to the Azure SQL databases and saw no delay at all. Each requests finished within milliseconds. Then I created a new Azure Functions app outside existing App Service Environment with a dedicated App Service plan. The result is the same, no delay at all.

Is there some missing configuration that is causing this slowness in App Service Environment? I tried to use tcpping to get latency amount to Azure SQL database, but the connection keeps timing out on ASE app. But it works fine on the kudu console of the non-ASE app.

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,679 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,456 Reputation points
    2022-01-27T14:01:38.373+00:00

    @Asiful Nobel ,

    Thanks for reaching out to Q&A.

    I would suggest you to look into the Diagnose and solve problems blade available in the portal to check the health of the ASE. Also the detector "Availability and Performance" will give you some additional insights about the performance delay.

    As you have already enabled App insights, you can look into the performance counters to analyze the latency further. From the code perspective, try add some timer logging so that you can identify which part of the code is taking longer time to execute. However the same code runs faster in a non-ASE SKU which means the problem might not be with the code.

    Strange observation is that the tcpping to SQL fails from the ASE Kudu site, this means that there is a problem with the network connectivity however if there is a network connectivity issue, the app wont even communciate with SQL. In your case, the app communicates and there is a latency. You can collect a network trace in the same Diagnose and solve section, search for "Collect network trace" and you will see that detector

    169077-image.png