Connect to Azure SQL Database From Visual Studio

For one of my clients, I had a requirement to perform some SQL operations by connecting to Azure SQL Database from Visual Studio. This article will guide you with my complete steps to achieve this.

How to connect to Azure SQL database from Visual Studio

Follow the below steps to connect to the Azure SQL Database from Visual Studio.

Before starting, as a Prerequisites, we need an Azure account. If you don’t have one, create a free Azure Account now.

Assuming you have a free account now, follow the below steps to connect to the Azure SQL from Visual Studio.

1. Log in to Azure Portal (https://portal.azure.com/)

2. Search for the SQL databases and click on the same search result.

How to Connect to Azure SQL Database From Visual Studio

3. You can now see the list of databases you have already created. Click on the one that you want to connect from the visual studio.

Connect to Azure SQL Database From Visual Studio

4. The next step is to set the server firewall rule.

To set the firewall rule, click on the Set server firewall button from the top on the Overview tab on your Database page.

how to connect to azure sql database from visual studio 2022

On the Firewall settings, you can set the Allow Azure services and resources to access this server option to Yes –> Click on the + Add client IP button and then click the Save button.

connect to azure sql from visual studio

Now you can see below I successfully updated the server firewall rules. click on the OK button.

how do i connect to my azure sql database from visual studio

Now you have successfully set the server firewall rule, so the next step is On the database page —> Overview tab —–> click on the Connect with button —-> Click on the Visual Studio.

how to connect to azure sql database from visual studio 2019

Now click on the Open in Visual Studio button.

how to connect to azure sql database from visual studio

Then, click on the Open Microsoft Visual Studio Web Protocol Handler Selector button on the below pop-up.

how do i connect to my azure sql database from visual studio 2019

Then, it will open the Visual Studio 2019 for me.

connect to azure sql database from visual studio 2019

Now you can see it connected successfully. The SQL Server Object Explorer window opens with a connection to the Azure SQL database.

visual studio connect to azure sql db

You may also like following the articles below

Conclusion

This is how to connect to Azure SQL Database from Visual Studio using the above steps mentioned in this article.