Quickstart: Deploy a Sample Database to Azure SQL Database

This guide provides a step-by-step process to quickly deploy a sample database to Azure SQL Database. This is a great way to get started with Azure SQL Database and explore its capabilities.

Deploy a fully functional sample database in minutes!

Prerequisites

Steps to Deploy

Step 1: Sign in to your Azure Account

Open your terminal or command prompt and run the following Azure CLI command to sign in:

az login

This will open a browser window for you to authenticate with your Azure credentials.

Step 2: Create an Azure SQL Server and Database

We'll create a resource group, a logical SQL server, and then deploy the sample AdventureWorksLT database. Replace <your-server-name> with a unique name for your SQL server.

Make sure <your-server-name> is globally unique. It can contain letters, numbers, and hyphens.

Run the following commands:

1. az group create --name AdventureWorksResourceGroup --location eastus
2. az sql server create --name <your-server-name> --resource-group AdventureWorksResourceGroup --location eastus --admin-user azureuser --admin-password <your-strong-password>
Note: Replace <your-strong-password> with a strong password that meets Azure's requirements.
3. az sql db create --resource-group AdventureWorksResourceGroup --server <your-server-name> --name AdventureWorksLT --edition Basic --service-objective Basic

This command deploys the AdventureWorksLT database, which is a small online transaction processing (OLTP) sample database.

Step 3: Configure Firewall Rules

To connect to your SQL server, you need to allow your IP address through the firewall. You can either manually add your current IP address or allow all Azure services and resources to access the server (not recommended for production).

Option A: Allow your current IP address

First, find your public IP address. Then, run the following command, replacing <your-server-name> and <your-ip-address>:

az sql server firewall-rule create --server <your-server-name> --resource-group AdventureWorksResourceGroup --name AllowMyIP --start-ip-address <your-ip-address> --end-ip-address <your-ip-address>

Option B: Allow Azure services (for testing/development only)

az sql server firewall-rule create --resource-group AdventureWorksResourceGroup --server <your-server-name> --name AllowAllWindowsAzureIps --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0
Warning: Allowing all Azure IPs is convenient for quick testing but poses a security risk in production environments.

Step 4: Connect to the Database

You can now connect to your Azure SQL Database using various tools:

Connection Details:

When connecting, you'll typically be prompted for the server name, authentication type, login, and password.

Next Steps