Overview
This quickstart guide will walk you through the essential steps to create and connect to an Azure SQL Managed Instance, a cloud-native fully managed SQL Server database engine. It offers near 100% compatibility with on-premises SQL Server and includes automated patching, backups, and high availability.
Prerequisites
- An Azure subscription. If you don't have one, create a free account before you begin.
- A virtual network (VNet) in Azure. If you don't have one, you'll be prompted to create it during the process.
- Permissions to create resources within your Azure subscription.
Step 1: Create an Azure SQL Managed Instance
You can create a SQL Managed Instance using the Azure portal, Azure CLI, or PowerShell. This guide uses the Azure portal for simplicity.
Navigate to SQL Managed Instance
Sign in to the Azure portal. In the search bar at the top, search for SQL Managed Instances and select it from the list.
Create New Instance
Click + Create. On the Basics tab:
- Subscription: Select your Azure subscription.
- Resource group: Select an existing resource group or create a new one.
- Virtual network: Choose your existing VNet or create a new one. Ensure the VNet has a dedicated subnet for the managed instance.
- Instance name: Enter a globally unique name for your instance (e.g.,
my-sql-mi-instance
). - Administrator login: Provide a login name.
- Password: Set a strong password for the administrator login.
- Version: Select the SQL Server version.
- Compute + Storage: Choose the appropriate service tier (General Purpose or Business Critical) and configure compute and storage. For quickstart, General Purpose is often sufficient.
Configure Networking
On the Networking tab, ensure your VNet and subnet are correctly selected. You might need to configure network security group rules and private endpoints depending on your connectivity requirements.
Review and Create
Review all the settings on the Review + create tab. If everything looks correct, click Create.
Provisioning an instance can take some time (typically 4-6 hours). You can monitor the deployment progress in the Azure portal.
Step 2: Connect to Your Instance
Once your SQL Managed Instance is deployed, you can connect to it using SQL Server Management Studio (SSMS) or Azure Data Studio.
Using SSMS
- Open SQL Server Management Studio (SSMS).
- In the Connect to Server dialog, enter the Fully qualified domain name (FQDN) of your managed instance. You can find this in the Azure portal under your instance's overview page. It will look something like
your-instance-name.your-dns-zone.database.windows.net
. - Select SQL Server Authentication.
- Enter the Administrator login and Password you created in Step 1.
- Click Connect.
Using Azure Data Studio
- Download and install Azure Data Studio if you haven't already.
- Open Azure Data Studio.
- In the Connections tab, click New Connection.
- Enter the Server name (the FQDN of your instance).
- Select SQL Login for Authentication Type.
- Enter your User name (Administrator login) and Password.
- Click Connect.
Step 3: Query Data
Once connected, you can execute SQL queries against your databases.
- In SSMS or Azure Data Studio, right-click on the
master
database and select New Query. - Execute a simple query, for example:
SELECT @@VERSION;
This query will return the SQL Server version information for your managed instance.
You can also create new databases and tables:
CREATE DATABASE MySampleDB;
GO
USE MySampleDB;
GO
CREATE TABLE dbo.Products (
ProductID int NOT NULL PRIMARY KEY,
ProductName varchar(50) NOT NULL,
Price money
);
GO
INSERT INTO dbo.Products (ProductID, ProductName, Price) VALUES (1, 'Chai', 18.00);
GO
SELECT * FROM dbo.Products;
GO
Next Steps
Congratulations! You have successfully created and connected to an Azure SQL Managed Instance.
Here are some recommended next steps:
- Learn more about configuring network security for your instance.
- Explore migrating your databases to Azure SQL Managed Instance.
- Understand performance tuning and best practices.
- Discover advanced features like read-scale availability and distributed transactions.