Introduction
In this article, you will learn about how to connect an Azure SQL database with Visual Studio code. Visual studio code is one of the most popular IDEs for programming and development in software fields. In case web developers developing web applications and Azure or other databases are a backend of web applications. During development time developers can test some DML operations in the database. Handling multiple tools is difficult in some places. So, we are going to connect the Azure SQL database in VS code.
Prerequisites
-
Azure cloud account
-
-
Edge (or) Other browsers
-
Stable Internet Connection
-
Minimum knowledge in Database
-
Azure SQL server & database
Step 1
Step 2
Go to your database Dashboard and then click the “Set server firewall” option at the top of the dashboard.
Step 3
In the firewall settings page, click the “Add client IP” button, our client IP added to the rule list. Next, click the “Save” button to save our client IP.
Step 4
Open your visual studio code IDE, first we install SQL tool in visual studio code. Click the “Extension” icon from the left sidebar and then search “SQL Tools' ' in the extension search bar. SQL tool is available in extension and then click the install button and wait a few minutes to complete the installation.
Step 5
After installation is completed, click the database icon and then click the “SQL Tools” icon and then click the “Add connection” icon at the connection area.
Step 6
Next, select “My SQL Server” on the connection assistance page.
Step 7
The connection settings page gives a “Connection name” and “Connection Method” to create a new connection.
Step 8
Next, we can get a connection string from Azure. So, go to the Azure SQL database dashboard and then select “Connection strings” from the left pane.
Copy the connection string from the “ADO.NET” tab.
Step 9
Next, come to the visual studio code, now paste the copied connection string and set the timeout. In the connection string, we can give our SQL server password. (Password is given during the server creation).
All of the fields are completed, click the “Test connection” button.
Step 10
Our connection is successful, click the “Save connection” button.
Step 11
In the connection review page, our connection information is displayed on that page. Click the “Connect now” button.
Step 12
Our database connection is established with a visual studio. On the left side pane, our database information is displayed, including the database name, table name and column name.
Summary
Execute the simple SELECT query in vs code to fetch all data from selected tables.
Finally, we have successfully connected our Azure SQL database with our Visual Studio code.