Home > Back-end >  Unable to authenticate SQL Server with Azure Active Directory using EFCore
Unable to authenticate SQL Server with Azure Active Directory using EFCore

Time:01-08

I am using Azure Function V4, Efcore with SQL server. We are authenticating using Password based approach but need to add Azure AD so that no password is required on the connectionstring. I have already added an Admin in SQL Server and Assigned roles to specific users so that from the GUI we don't need password to access SQL server. That is working but I need to replicate the same behavior in the app.

Steps I followed to replicate -

  1. Created user assigned identity resource.
  2. Enabled identity and assigned the user identity resource to SQL Server.
  3. Added user assigned identity resource to my Function app.
  4. Modified connection string with Authentication=Active Directory Managed Identity and User Id = $usermanagedidentity.clientid

But I am getting errors when querying from the code => unable to fetch token.

Techstack:

  • Azure Function v4
  • .net 6
  • efcore 6
  • SQL Client 2.1.4

Is there anything that I missed or need to do? Help is very much appreciated.

CodePudding user response:

Thanks, @ErikEJ for helping me out. The issue was in the version. Once I have upgraded the SQL Client and given the appropriate permission to the database it is flying.

  • Related