SQL Database application development overview
This article walks through the basic considerations that a developer should be aware of when writing code to connect to Azure SQL Database. This article applies to all deployment models of Azure SQL Database (Single database, Elastic pools, Managed instance).
Language and platform
You can leverage open-source tools like cheetah, sql-cli, VS Code. Additionally, Azure SQL Database works with Microsoft tools like Visual Studio and SQL Server Management Studio. You can also use the Azure portal, PowerShell, and REST APIs help you gain additional productivity.
Access to Azure SQL Database is protected with logins and firewalls. Azure SQL Database supports both SQL Server and Azure Active Directory (AAD) authentication users and logins. AAD logins are available only in Managed Instance.
Learn more about managing database access and login.
In your client connection logic, override the default timeout to be 30 seconds. The default of 15 seconds is too short for connections that depend on the internet.
If you are using a connection pool, be sure to close the connection the instant your program is not actively using it, and is not preparing to reuse it.
Avoid long-running transactions because any infrastructure or connection failure might roll back the transaction. If possible, split the transaction in the multiple smaller transactions and use batching to improve performance.
Azure SQL Database is a cloud service where you might expect transient errors that happen in the underlying infrastructure or in the communication between cloud entities. Although Azure SQL Database is resilient on the transitive infrastructure failures, these failures might affect your connectivity. When a transient error occurs while connecting to SQL Database, your code should retry the call. We recommend that retry logic use backoff logic, so that it does not overwhelm the SQL Database with multiple clients retrying simultaneously. Retry logic depends on the error messages for SQL Database client programs.
For more information about how to prepare for planned maintenance events on your Azure SQL database, see planning for Azure maintenance events in Azure SQL Database.
- On the computer that hosts your client program, ensure the firewall allows outgoing TCP communication on port 1433. More information: Configure an Azure SQL Database firewall.
- If your client program connects to SQL Database while your client runs on an Azure virtual machine (VM), you must open certain port ranges on the VM. More information: Ports beyond 1433 for ADO.NET 4.5 and SQL Database.
- Client connections to Azure SQL Database sometimes bypass the proxy and interact directly with the database. Ports other than 1433 become important. For more information, Azure SQL Database connectivity architecture and Ports beyond 1433 for ADO.NET 4.5 and SQL Database.
- For networking configation for a managed instance, see network configuration for managed instances.
Explore all the capabilities of SQL Database.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.