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.

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.

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.

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.

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

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.

Now click on the Open in Visual Studio button.

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

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

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

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.

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
