- Article
- 5 minutes to read
Applies to: Azure SQL Database
Azure SQL Managed Instance
The following document includes links to Azure examples showing how to connect and query Azure SQL Database and Azure SQL Managed Instance. For some related recommendations for Transport Level Security, see TLS considerations for database connectivity.
Quickstarts
Quickstart | Description |
---|---|
SQL Server Management Studio | This quickstart demonstrates how to use SSMS to connect to a database, and then use Transact-SQL statements to query, insert, update, and delete data in the database. |
Azure Data Studio | This quickstart demonstrates how to use Azure Data Studio to connect to a database, and then use Transact-SQL (T-SQL) statements to create the TutorialDB used in Azure Data Studio tutorials. |
Azure portal | This quickstart demonstrates how to use the Query editor to connect to a database (Azure SQL Database only), and then use Transact-SQL statements to query, insert, update, and delete data in the database. |
Visual Studio Code | This quickstart demonstrates how to use Visual Studio Code to connect to a database, and then use Transact-SQL statements to query, insert, update, and delete data in the database. |
.NET with Visual Studio | This quickstart demonstrates how to use the .NET framework to create a C# program with Visual Studio to connect to a database and use Transact-SQL statements to query data. |
.NET core | This quickstart demonstrates how to use .NET Core on Windows/Linux/macOS to create a C# program to connect to a database and use Transact-SQL statements to query data. |
Go | This quickstart demonstrates how to use Go to connect to a database. Transact-SQL statements to query and modify data are also demonstrated. |
Java | This quickstart demonstrates how to use Java to connect to a database and then use Transact-SQL statements to query data. |
Node.js | This quickstart demonstrates how to use Node.js to create a program to connect to a database and use Transact-SQL statements to query data. |
PHP | This quickstart demonstrates how to use PHP to create a program to connect to a database and use Transact-SQL statements to query data. |
Python | This quickstart demonstrates how to use Python to connect to a database and use Transact-SQL statements to query data. |
Ruby | This quickstart demonstrates how to use Ruby to create a program to connect to a database and use Transact-SQL statements to query data. |
Get server connection information
Get the connection information you need to connect to the database in Azure SQL Database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
Sign in to the Azure portal.
Navigate to the SQL Databases or SQL Managed Instances page.
On the Overview page, review the fully qualified server name next to Server name for the database in Azure SQL Database or the fully qualified server name (or IP address) next to Host for an Azure SQL Managed Instance or SQL Server on Azure VM. To copy the server name or host name, hover over it and select the Copy icon.
Note
For connection information for SQL Server on Azure VM, see Connect to a SQL Server instance.
Get ADO.NET connection information (optional - SQL Database only)
Navigate to the database blade in the Azure portal and, under Settings, select Connection strings.
Review the complete ADO.NET connection string.
Copy the ADO.NET connection string if you intend to use it.
TLS considerations for database connectivity
Transport Layer Security (TLS) is used by all drivers that Microsoft supplies or supports for connecting to databases in Azure SQL Database or Azure SQL Managed Instance. No special configuration is necessary. For all connections to a SQL Server instance, a database in Azure SQL Database, or an instance of Azure SQL Managed Instance, we recommend that all applications setthe following configurations, or their equivalents:
- Encrypt = On
- TrustServerCertificate = Off
Some systems use different yet equivalent keywords for those configuration keywords. These configurations ensure that the client driververifies the identity of the TLS certificate received from the server.
We also recommend that you disable TLS 1.1 and 1.0 on the client if you need to comply with Payment Card Industry - Data SecurityStandard (PCI-DSS).
Non-Microsoft drivers might not use TLS by default. This can be a factor when connecting to Azure SQL Database or Azure SQL Managed Instance. Applications with embedded drivers might not allow you to control these connection settings. We recommend that you examine the security of such drivers and applications before using them on systems that interact with sensitive data.
Drivers
The following minimal versions of the tools and drivers are recommended if you want to connect to Azure SQL database:
Driver/tool | Version |
---|---|
.NET Framework | 4.6.1 (or .NET Core) |
ODBC driver | v17 |
PHP driver | 5.2.0 |
JDBC driver | 6.4.0 |
Node.js driver | 2.1.1 |
OLEDB driver | 18.0.2.0 |
SMO | 150 or higher |
Libraries
You can use various libraries and frameworks to connect to Azure SQL Database or Azure SQL Managed Instance. Check out our Get started tutorials to quickly get started with programming languages such as C#, Java, Node.js, PHP, and Python. Then build an app by using SQL Server on Linux or Windows or Docker on macOS.
The following table lists connectivity libraries or drivers that client applications can use from a variety of languages to connect to and use SQL Server running on-premises or in the cloud. You can use them on Linux, Windows, or Docker and use them to connect to Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse Analytics.
Language | Platform | Additional resources | Download | Get started |
---|---|---|---|---|
C# | Windows, Linux, macOS | Microsoft ADO.NET for SQL Server | Download | Get started |
Java | Windows, Linux, macOS | Microsoft JDBC driver for SQL Server | Download | Get started |
PHP | Windows, Linux, macOS | PHP SQL driver for SQL Server | Download | Get started |
Node.js | Windows, Linux, macOS | Node.js driver for SQL Server | Install | Get started |
Python | Windows, Linux, macOS | Python SQL driver | Install choices: * pymssql * pyodbc | Get started |
Ruby | Windows, Linux, macOS | Ruby driver for SQL Server | Install | Get started |
C++ | Windows, Linux, macOS | Microsoft ODBC driver for SQL Server | Download |
Data-access frameworks
The following table lists examples of object-relational mapping (ORM) frameworks and web frameworks that client applications can use with SQL Server, Azure SQL Database, Azure SQL Managed Instance, or Azure Synapse Analytics. You can use the frameworks on Linux, Windows, or Docker.
Language | Platform | ORM(s) |
---|---|---|
C# | Windows, Linux, macOS | Entity Framework Entity Framework Core |
Java | Windows, Linux, macOS | Hibernate ORM |
PHP | Windows, Linux, macOS | Laravel (Eloquent) Doctrine |
Node.js | Windows, Linux, macOS | Sequelize ORM |
Python | Windows, Linux, macOS | Django |
Ruby | Windows, Linux, macOS | Ruby on Rails |
Next steps
- For connectivity architecture information, see Azure SQL Database Connectivity Architecture.
- Find SQL Server drivers that are used to connect from client applications.
- Connect to Azure SQL Database or Azure SQL Managed Instance:
- Connect and query using .NET (C#)
- Connect and query using PHP
- Connect and query using Node.js
- Connect and query using Java
- Connect and query using Python
- Connect and query using Ruby
- Install sqlcmd and bcp the SQL Server command-line tools on Linux - For Linux users, try connecting to Azure SQL Database or Azure SQL Managed Instance using sqlcmd.
- Retry logic code examples:
FAQs
Does Azure SQL managed instance support cross database query? ›
Azure SQL Database does not support cross-database and cross-instance queries using three-part or four-part names, so depending on your needs, Make sure the source database will be an Azure SQL Managed Instance And The target database will be an Azure SQL Database.
How to connect to SQL Azure database from SQL Management Studio? ›- Authenticate to the Azure Portal.
- Click on SQL Databases.
- Click on Servers.
- Click on the name of the Server you wish to connect to…
- Click on Configure…
- Open SQL Management Studio and connect to Database services (usually comes up by default)
- Hit the Connect button.
Azure SQL managed instance provides integration of native virtual network while azure SQL database enables the access of restricted virtual network by using endpoints of Vnet.
Can we connect to Azure SQL Database using SQL Server Management Studio? ›Connect and query a SQL Server instance on an Azure VM using SQL Server Management Studio (SSMS) - SQL Server Management Studio (SSMS) Connect to a SQL Server instance on an Azure VM using SSMS. Create and query SQL Server on an Azure VM by running basic T-SQL queries in SSMS.
What is the difference between Azure SQL VM and managed instance? ›SQL Managed Instance (SQL MI) provides native Virtual Network (VNet) integration while Azure SQL Database enables restricted Virtual Network (VNet) access using VNet Endpoints. SQL MI helps bridge the gap between Azure SQL Database and On-premises SQL Server due to being built on an instance scoped configuration model.
What are the limitations of Azure SQL managed instance? ›Up to 280, unless the instance storage size or Azure Premium Disk storage allocation space limit has been reached. 32,767 files per database, unless the instance storage size limit has been reached. Maximum size of each data file is 8 TB. Use at least two data files for databases larger than 8 TB.
How do I connect to an Azure SQL Server instance? ›- On the File menu, select Connect to SQL Azure (this option is enabled after the creation of a project). ...
- In the connection dialog box, enter or select the server name of Azure SQL Database.
- Enter, select, or Browse the Database name.
- Enter or select Username.
- Enter the Password.
To get started with [sqlcmd][sqlcmd], open the command prompt and enter sqlcmd followed by the connection string for your dedicated SQL pool. The connection string requires the following parameters: Server (-S): Server in the form < Server Name > .
How do I connect to Azure SQL Database using ODBC? ›In Windows, search for ODBC Data Sources, and open the ODBC Data Sources desktop app. Select Add. Select ODBC Driver 17 for SQL Server then Finish. Enter a name and description for the connection and the cluster you want to connect to, then select Next.
What's the default connection policy for Azure SQL Database and Azure SQL managed instance? ›The default policy is Redirect for all client connections originating inside of Azure (for example, from an Azure Virtual Machine) and Proxy for all client connections originating outside (for example, connections from your local workstation).
How do I migrate Azure SQL Database to Azure SQL managed instance? ›
- 1 – Create a storage account to upload backups. ...
- 2 – Install Azure Data Studio and add SQL Migration extension. ...
- 3 – Launch the “Migrate to Azure SQL” wizard in Azure Data Studio.
SQL Managed Instance provides high compatibility with the SQL Server database engine, and most features are supported in a SQL Managed Instance. There are some PaaS limitations that are introduced in SQL Managed Instance and some behavior changes compared to SQL Server.
What is the only prerequisite for connecting to a database in Azure SQL Database? ›Prerequisites. To complete this quickstart, you need Azure Data Studio, and an Azure SQL Database server. If you don't have an Azure SQL server, complete one of the following Azure SQL Database quickstarts.
Can you use SQL Server Management Studio to connect to an azure cosmos DB database? ›Once you set up an Azure Cosmos DB ODBC Driver User DSN, you can query Azure Cosmos DB from SQL Server Management Studio (SSMS) by setting up a linked server connection. Install SQL Server Management Studio and connect to the server.
Which tools can be used to connect to Azure SQL Database? ›- SQL Server.
- Analysis Services (SSAS)
- Integration Services (SSIS)
- Reporting Services (SSRS)
- SQL Server Management Studio (SSMS)
- SQL Server Data Tools (SSDT)
- Azure Data Studio.
SQL Managed Instance provides additional security isolation from other tenants on the Azure platform. Security isolation includes: Native virtual network implementation and connectivity to your on-premises environment using Azure ExpressRoute or VPN Gateway.
What is the difference between Azure SQL Database and SQL Server on VM? ›Azure SQL Database offers Database-as-a-service (DBaaS-PaaS). With SQL Database, you don't have access to the machines that host your databases. In contrast, Azure Virtual Machine offers Infrastructure-as-a-service (IaaS). Running SQL Server on an Azure VM is similar to running SQL Server in a On-Premise datacenter.
What are the two instance types in SQL Server? ›- Default instance.
- Named instance.
The limit of 100 databases per SQL Managed Instance is a hard limit that cannot be changed.
When using an Azure SQL Database managed instance What is the simplest way to implement backups? ›The simplest way to do so is to create a backup of your on-premises database, move it to Azure Blob storage, and restore the database on managed instance using a standard RESTORE DATABASE …. FROM URL T-SQL statement.
What are the options for managed SQL databases on Azure? ›
Azure offers a choice of fully managed relational, NoSQL, and in-memory databases, spanning proprietary and open-source engines, to fit the needs of modern app developers. Infrastructure management—including scalability, availability, and security—is automated, saving you time and money.
How do I connect to a specific instance of SQL Server? ›Start SQL Server Management Studio. The first time you run SSMS, the Connect to Server window opens. If it doesn't open, you can open it manually by selecting Object Explorer > Connect > Database Engine. For Server type, select Database Engine (usually the default option).
How do I connect to an instance of a database? ›To connect to a DB instance, use any client for a DB engine. For example, you might use the mysql utility to connect to a MariaDB or MySQL DB instance. You might use Microsoft SQL Server Management Studio to connect to a SQL Server DB instance. You might use Oracle SQL Developer to connect to an Oracle DB instance.
How do I connect to a SQL instance in cloud? ›In the Google Cloud console, go to the Cloud SQL Instances page. To open the Overview page of an instance, click the instance name. Select Connections from the SQL navigation menu. In the Authorized networks section, click Add network and enter the IP address of the machine where the client is installed.
How do I query data from Azure SQL Database? ›- On your SQL database Overview page in the Azure portal, select Query editor (preview) from the left menu.
- On the sign-in screen, provide credentials to connect to the database. You can connect using SQL authentication or Azure AD.
Grant your VM access to Azure SQL Database. Enable Azure AD authentication. Create a contained user in the database that represents the VM's system assigned identity. Get an access token using the VM identity and use it to query Azure SQL Database.
How do I get data from Azure SQL Database? ›- In the Azure portal, navigate to your SQL server. Select Firewalls and virtual networks from left navigation.
- Select Yes for Allow Azure services and resources to access this server.
- Select +Add client IP. ...
- Select Save.
Azure Synapse SQL is a big data analytic service that enables you to query and analyze your data using the T-SQL language. You can use standard ANSI-compliant dialect of SQL language used on SQL Server and Azure SQL Database for data analysis.
How to connect to Azure SQL Database using private endpoint? ›- Select Resource groups in the left-hand navigation pane.
- Select CreateSQLEndpointTutorial.
- Select myVM.
- On the overview page for myVM, select Connect then Bastion.
Azure SQL Managed Instance supports the following two connection types: Redirect (recommended): Clients establish connections directly to the node hosting the database. To enable connectivity using redirect, you must open firewalls and Network Security Groups (NSG) to allow access on ports 1433, and 11000-11999.
How do you create a linked server from Azure SQL managed instance to SQL Server Azure VM? ›
To do that, open SQL Server Management Studio and connect to the local instance. In object explorer, expand Server Objects > Linked Servers and right click and select "New Linked Server." Now click on Security. On this page, we can configure the security options.
What is the connection type of Azure managed instance? ›The connection types are used to select the way that the customer connects to an Azure SQL Managed Instance. There are two main options: Redirect, where the clients establish a connection directly to the node that hosts the database. Proxy, where the connections use a proxy gateway.
What feature is not available with Azure SQL Database managed instance? ›Yes, for Azure Data Lake Storage (ADLS) and Azure Blob Storage as data source. See Data Virtualization with Azure SQL Managed Instance for more details. Only Full Recovery that guarantees high availability is supported. Simple and Bulk Logged recovery models are not available.
Which of the following is not supported in Azure SQL Database? ›Specifically, Azure SQL Edge doesn't support SQL Server components like Analysis Services, Reporting Services, Integration Services, Master Data Services, Machine Learning Services (In-Database), and Machine Learning Server (standalone).
Which is not supported in SQL Azure? ›Procedures and Triggers are not supported in the Azure SQL Managed Instance.
Does SQL managed instance support linked server? ›The Managed Instance link is supported on both the General Purpose and Business Critical service tier of Azure SQL Managed Instance. To use the link feature with SQL Server, you'll need a supported Enterprise, Standard, or Developer edition of SQL Server running on Windows Server.
How do I connect to an Azure SQL Database? ›- On the File menu, select Connect to SQL Azure (this option is enabled after the creation of a project). ...
- In the connection dialog box, enter or select the server name of Azure SQL Database.
- Enter, select, or Browse the Database name.
- Enter or select Username.
- Enter the Password.
SQL Managed Instance provides additional security isolation from other tenants on the Azure platform. Security isolation includes: Native virtual network implementation and connectivity to your on-premises environment using Azure ExpressRoute or VPN Gateway.
Which account can always connect to Azure SQL Database? ›The Server admin and Azure AD admin accounts have the following characteristics: Are the only accounts that can automatically connect to any SQL Database on the server. (To connect to a user database, other accounts must either be the owner of the database, or have a user account in the user database.)
Which tool can be used to connect Azure SQL? ›Connecting to an Azure SQL Database with SQL Server Management Studio (SSMS) By far the most robust tool for managing a SQL Database server is SSMS.
What type of database is Azure SQL? ›
Azure SQL Database is a fully managed platform as a service (PaaS) database engine that handles most of the database management functions such as upgrading, patching, backups, and monitoring without user involvement.
What are the types of SQL in Azure? ›- Single Database—a single database, deployed to an Azure VM and managed with a SQL Database server. This is the most basic deployment model.
- Elastic Pool—a group of connected databases that share pooled resources.
- Managed Instance—a fully-managed database instance.
Azure Synapse SQL is a big data analytic service that enables you to query and analyze your data using the T-SQL language. You can use standard ANSI-compliant dialect of SQL language used on SQL Server and Azure SQL Database for data analysis.
How do I create a linked server in Azure SQL managed instance? ›- Start your Management Studio and choose your SQL Server instance.
- In the Object Explorer pane, expand the Server Objects, right-click on Linked Servers and then click on New Linked Server.
To do that, open SQL Server Management Studio and connect to the local instance. In object explorer, expand Server Objects > Linked Servers and right click and select "New Linked Server." Now click on Security.