Connecting to SQL Database in VS Code - User not found in MSAL cache

Zachary Lehmann 10 Reputation points
2023-06-15T14:22:29.2666667+00:00

I have a SQL server and database setup on my Azure account. I am trying to use the MSSQL extension in VS Code to connect to that database. When I go through the connection process using the AAD authentication it will prompt me to connect via a new browser window. That seems to work successfully, but then I get an error saying the user could not be found in the MSAL cache.

I'm brand new to azure and have no idea how to fix this. I've been googling solutions for a few days now with no luck. Can anyone help point me in the right direction?

Azure SQL Database
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,409 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Timo Riikonen 26 Reputation points
    2023-07-28T11:02:40.31+00:00

    I got this error:

    1. Using Azure Data Studio
    2. I tried to connect to the SQL service, but it failed
    3. After I had solved my connection issue, Data Studio had forgotten my session
    4. Logged in and renewed the session.
    5. Got this error

    I fixed this:

    1. I used SSMS instead

    Restarting Data Studio might work as well, but I didn't test this.

    1 person found this answer helpful.

  2. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2023-06-15T19:57:28.69+00:00

    @Zachary Lehmann Thank you for reaching out.

    Could you please provide more details about the error message you are getting.

    Did you do the right configuration in the Azure portal.? Under set firewall - Public Network, selected "selected networks."
    Enabled allow Azure services and resources to access this server.
    This also can be caused by internal restrictions set by the company.

    Are you using integrated or AAD universal/MFA Support.?

    You will need to create a firewall rule in the Azure portal under the server blade.

    https://learn.microsoft.com/en-us/azure/azure-sql/database/firewall-create-server-level-portal-quickstart?view=azuresql

    User's image

    I am following this doc https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-vscode?view=azuresql#connect-to-your-database

    • Please don't forget to click on 130616-image.png

    and upvote 130671-image.png

    button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how

    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

    Regards,

    Oury


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.