visual studio code mssql not connecting to database

kosmos 246 Reputation points
2022-10-13T07:22:00.857+00:00

I am using Visual Code Studio (VSC) to connect to Synapse SQL Dedicated Pool.
After following many tutorials and using the extension SQL tools I am not able to connect to the Dedicated pool. I have succeeded temporaly but onnce I close VSC I lose the connection.

I am connecting via Azure Active Directory - Universal w/ MFA Support

The errors I am having are:

mssql: Credential Error: Account credentials have expired. Please re-authenticated. Source: SQL Server (mmsql)

First when I press "Refresh credentials" it opens my browser with localhost. Which should not be the case. I swichted in File-->Preferences-->Settings-->Remote from localhost to allInterfaces.
It worked for one day, then I closed VSC opened again and it redirects me again to local host.+

Even when it redirects me to azure login auth it shows me the following errors in VSC

mssql: undefined
mssql: Error Login Failed. Retry using different Credentials. Source: SQL Server (mmsql)

I have spent 2 days researching without success.

Could someone please help me ?

hi @Bhargava-MSFT , I used your proposal and just worked temporaly and then did not work anymore. Could you also please support here ?

https://learn.microsoft.com/en-us/answers/questions/1043205/is-it-possible-to-connect-visual-studio-code-with.html?childToView=1045483#comment-1045483

Update: it works with SQL Login by using the sqladmin user after reseting the settings.json file

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,696 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bhargava-MSFT 29,266 Reputation points Microsoft Employee
    2022-10-13T21:00:46.313+00:00

    Hello @kosmos ,
    Welcome to the MS Q&A platform.

    Sorry, I cannot see the Azure active directory- Universal w/MFA support using the SQL server/azure driver. I only see the username and password.

    I have gone ahead and installed the SQL server(MSSQL) extension. After this, I was able to use AAD with MFA. Now I see a new 'server symbol' in the left side pane.

    Once installing the extension, please follow the below steps to connect to dedicated pools using AAD with MFA.

    How to Connect to your synapse dedicated pool using VS code:

    In Visual Studio Code, press Ctrl+Shift+P (or F1) to open the Command Palette.

    Select MS SQL:Connect and choose Enter.

    Select Create Connection Profile.

    Follow the prompts to specify the new profile's connection properties. After specifying each value, choose Enter to continue.

    Reference document: https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-vscode?view=azuresql#connect-to-your-database

    250203-image.png

    250271-image.png

    ------------------------------

    • 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

0 additional answers

Sort by: Most helpful