GetADALAccessToken timeout exception when using EF6.2 with .NET framework 4.7.2

Siv Siri 21 Reputation points

I have a .NET Framework 4.7.2 web app that is using EF6.2 (Entity Framework) on 2012R2 server, connecting to an on-prem SQL server without any issues. Now, I am trying to connect the same app to an Azure SQL MI database from an Azure VM (2019 server) and I get ADAL-related errors. A console application with an Azure AD Password connection string works fine on the same machine. Also, the EF app works fine on the 2012 server, it is the EF version app on the 2019 Azure server VMs that is having the issues. Any pointers in resolving this is really appreciated.

This is the connection string:

<add name="MyEntities" connectionString="metadata=res:///EntityFramework.XXX.csdl|res:///EntityFramework.XXXX.ssdl|res://*/EntityFramework.XXX.msl;provider=System.Data.SqlClient;provider connection string='data;initial catalog=testDB;persist security info=True;user id=Email address removed;password=XXXX;authentication="Active Directory Password";MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />

This is the error:

InnerException: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> AdalException: The request has timed out. at ADALNativeWrapper.ADALGetAccessToken
in XXXXX\source\repos\SampleEF\DataObjects\EntityFramework\XXXX.cs:line 19

Microsoft Technologies based on the .NET software framework.
3,545 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,136 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,187 questions
0 comments No comments
{count} votes

Accepted answer
  1. Marilee Turscak-MSFT 35,806 Reputation points Microsoft Employee

    Hi @Siv Siri ,

    I understand that you are seeing the Adal timeout error in your Entity Framework app on your Azure VM and getting the InnerException:

    AdalException: The request has timed out. at ADALNativeWrapper.ADALGetAccessToken

    I'm not sure if you have already seen the troubleshooting document for this issue, but this error often occurs access to the Azure Active Directory is blocked by your proxy or firewall.

    To resolve this issue, try the following steps:

    1) In addition to the outgoing port 1433, open your proxy or firewall for additional URLs or IP ranges. The full range is documented in Troubleshoot Azure AD connectivity

    2) Make sure that the proxy server has the required URLs opened.

    3) Open *

    4) Make sure that the bare minimum connection requirements documented in the table are met.

    5) Upgrade to ADAL 6.0. 1

    It is also worth noting that ADAL support is going away in December, so the recommendation is to migrate to MSAL.

    Let me know if this helps.


    If this answer helped resolve your question, please remember to "mark as answer" so that others in the community with similar questions can more easily find a solution.

0 additional answers

Sort by: Most helpful