Get Started with Azure SQL Database

Welcome to Azure SQL Database! This guide will walk you through the essential steps to create and connect to your first Azure SQL Database instance. Whether you're building a new application or migrating an existing one, Azure SQL Database provides a powerful, scalable, and fully managed relational database service.

What you'll learn:
  • How to create an Azure SQL Database server and database.
  • How to configure firewall rules.
  • How to connect to your database using SQL Server Management Studio (SSMS).

Prerequisites

Before you begin, ensure you have the following:

Step 1: Create an Azure SQL Database Server and Database

You can create your Azure SQL Database resources through the Azure portal, Azure CLI, or PowerShell. This guide will use the Azure portal for simplicity.

1

Sign in to the Azure portal.

2

In the Azure portal search bar, type "SQL databases" and select SQL databases from the results.

3

Click + Create to open the "Create SQL database" page.

4

On the Basics tab:

  • Subscription: Select your Azure subscription.
  • Resource group: Create a new one (e.g., `sql-db-rg`) or select an existing one.
  • Database name: Enter a name for your database (e.g., `mydatabase`).
  • Server: Click Create new.
5

In the "Create SQL server" dialog:

  • Server name: Enter a globally unique server name (e.g., `myazuresqlserver-unique`). The portal will check for availability.
  • Location: Choose an Azure region close to you or your users.
  • Admin login: Enter a username for the server administrator (e.g., `sqladmin`).
  • Password: Enter a strong password and confirm it.
  • Click OK.
6

Back on the "Create SQL database" page, under Workload environment, select Development for testing or Production for live applications. For this quickstart, Development is fine.

7

Under Compute + storage, click Configure database. For getting started, the default General Purpose tier with a suitable vCore count is recommended. You can choose a Serverless option for auto-scaling and cost-effectiveness.

Tip: For free tier or cost-effective testing, explore the Basic or Serverless options.

Click Apply.

8

Review the other tabs (Networking, Security, etc.) as needed. For this guide, defaults are sufficient. Click Review + create, then Create.

It will take a few minutes for the server and database to be provisioned. You'll see a notification when it's complete.

Step 2: Configure Firewall Rules

By default, Azure SQL Database is protected by a firewall. You need to allow your local IP address to connect.

1

Navigate to your newly created Azure SQL server resource in the Azure portal.

2

In the left-hand menu, under Security, click Firewalls and virtual networks.

3

Click the Add client IP button. This automatically adds your current public IP address to the allowed list.

4

You can optionally give this rule a name and specify a range of IP addresses. For a single machine, adding the client IP is usually sufficient.

5

Click Save.

Security Note: For production environments, avoid using "Allow Azure services and resources to access this server" unless absolutely necessary. It's more secure to define specific IP ranges or use Azure Private Link.

Step 3: Connect to Your Database

Now that your database is created and accessible, let's connect to it using SQL Server Management Studio (SSMS).

1

Open SQL Server Management Studio (SSMS).

2

In the Connect to Server dialog:

  • Server name: Enter the fully qualified server name. You can find this on the Overview page of your SQL server in the Azure portal (it will look something like `myazuresqlserver-unique.database.windows.net`).
  • Authentication: Select SQL Server Authentication.
  • Login: Enter the admin login you created earlier (e.g., `sqladmin`).
  • Password: Enter the password you set for the admin login.
3

Click Connect.

If the connection is successful, you'll see your Azure SQL server in the Object Explorer. Expand the Databases folder to see your newly created database (e.g., `mydatabase`). You can now run T-SQL queries against your database.

Next Steps:

Troubleshooting Common Connection Issues

Connection timed out

This usually means the firewall is blocking your connection. Double-check that your client IP is added to the server's firewall rules in the Azure portal.

Login failed for user '...'

Verify that you are using the correct username and password. Ensure you are using SQL Server Authentication and not Windows Authentication.

For more advanced connection scenarios, consider using Azure Active Directory authentication for enhanced security and manageability.