Create an Azure SQL Database

This guide provides step-by-step instructions on how to create a new Azure SQL Database instance. You can create an Azure SQL Database using the Azure portal, Azure CLI, Azure PowerShell, or programmatically.

Note: Before you begin, ensure you have an Azure subscription. If you don't have one, you can create a free account.

Using the Azure Portal

The Azure portal offers a user-friendly interface for creating and managing Azure resources.

1

Sign in to the Azure Portal

Open your web browser and navigate to https://portal.azure.com/. Sign in with your Azure account credentials.

2

Navigate to SQL Databases

In the Azure portal, search for "SQL databases" in the top search bar and select "SQL databases" from the results.

Azure Portal search for SQL databases
3

Create a new SQL Database

Click the "+ Create" button. On the "Create SQL database" page, configure the following settings:

  • Subscription: Select the Azure subscription to use.
  • Resource group: Choose an existing resource group or create a new one. A resource group is a logical container for your Azure resources.
  • Database name: Enter a unique name for your SQL database (e.g., MySampleDatabase).
  • Server: Select an existing SQL server or click "Create new" to create a new server. A server hosts one or more databases.

If creating a new server, you'll need to provide:

  • Server name: A globally unique name.
  • Location: The Azure region where the server will be hosted.
  • Administrator username: The username for logging into the server.
  • Password: A strong password for the administrator account.
Azure Portal SQL Database creation settings
4

Configure Compute + Storage

Click on the "Compute + storage" tab. Here you can select the service tier (e.g., Basic, Standard, Premium, General Purpose, Business Critical) and the compute size (DTUs or vCores) that best suits your performance and cost requirements.

For initial testing, the Basic or Standard S0 tiers are often sufficient.

Azure Portal Compute + Storage settings
5

Review + Create

Click the "Review + create" button. Azure will validate your configuration. Once validation passes, review the summary and click the "Create" button.

Tip: You can use the "Networking" tab to configure firewall rules and VNet service endpoints to control access to your database.

Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources from your terminal.

Prerequisites

Create a Resource Group (if needed)


az group create --name MyResourceGroup --location eastus
        

Create a SQL Server


az sql server create --name mysqldemoserver-123 --resource-group MyResourceGroup --location eastus --admin-user sqladmin --admin-password 'your_strong_password'
        

Replace mysqldemoserver-123 with a globally unique server name and your_strong_password with a strong password.

Create the SQL Database


az sql db create --resource-group MyResourceGroup --server mysqldemoserver-123 --name MySampleDatabase --edition Basic
        

This command creates a database named MySampleDatabase on the specified server with the Basic edition. You can choose other editions like Standard or Premium.

Next Steps

Get Started with Azure SQL Database