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.
Using the Azure Portal
The Azure portal offers a user-friendly interface for creating and managing Azure resources.
Sign in to the Azure Portal
Open your web browser and navigate to https://portal.azure.com/. Sign in with your Azure account credentials.
Navigate to SQL Databases
In the Azure portal, search for "SQL databases" in the top search bar and select "SQL databases" from the results.
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.
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.
Review + Create
Click the "Review + create" button. Azure will validate your configuration. Once validation passes, review the summary and click the "Create" button.
Using Azure CLI
The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources from your terminal.
Prerequisites
- Install Azure CLI.
- Log in to your Azure account:
az login
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.