Quickstart: Create an Azure SQL Database
This guide will walk you through the process of creating your first Azure SQL Database using the Azure portal.
Prerequisites
Before you begin, ensure you have:
- An Azure subscription. If you don't have one, create a free account before you begin.
- Access to the Azure portal.
Step 1: Sign in to the Azure portal
Open your web browser and navigate to portal.azure.com. Sign in with your Azure account credentials.
Step 2: Create a SQL server
A SQL database needs a logical SQL server to host it. Follow these steps to create a new server:
Navigate to SQL servers
In the Azure portal search bar, type "SQL servers" and select SQL servers from the results.
Create a new server
Click the + Create button. This will open the "Create SQL server" blade.
Configure server details
Fill in the following details:
- Subscription: Select your Azure subscription.
- Resource group: Create a new one (e.g.,
myResourceGroup
) or select an existing one. - Server name: Enter a globally unique name (e.g.,
yourunique-sqlserver-name
). - Location: Choose an Azure region.
- Administrator login: Enter a username (e.g.,
sqladmin
). - Password: Enter a strong password.
- Confirm password: Re-enter the password.
Review and create
Click the Review + create button, then click Create.
It may take a few minutes for the server to be provisioned.
Step 3: Create a SQL database
Now that you have a server, you can create a database on it.
Navigate to SQL databases
In the Azure portal search bar, type "SQL databases" and select SQL databases from the results.
Create a new database
Click the + Create button.
Configure database details
Fill in the following details:
- Subscription: Select your Azure subscription.
- Resource group: Select the same resource group used for your server.
- Server: Select the server you just created from the dropdown.
- Database name: Enter a name for your database (e.g.,
mySampleDatabase
). - Compute + storage: Click Configure database to choose a service tier. For this quickstart, the Basic tier is sufficient.
Review and create
Click Apply on the "Configure database" blade, then click Review + create, and finally click Create.
Your database will be provisioned shortly.
Step 4: Connect to your database
Once your database is created, you can connect to it using various tools like Azure Data Studio or SQL Server Management Studio (SSMS).
Get your server name
You can find your server's fully qualified domain name (FQDN) on the SQL server's overview page in the Azure portal. It will look something like yourunique-sqlserver-name.database.windows.net
.
Configure firewall rules
To connect from your local machine, you need to add your client IP address to the server's firewall rules.
Navigate to your SQL server
Go to your SQL server's page in the Azure portal.
Access Firewall settings
Under the Security section, click on Firewalls and virtual networks.
Add client IP
Click the Add client IP button. This will automatically detect your current public IP address and add it as a firewall rule. You can also manually enter IP addresses or ranges.
Save changes
Click Save.
Allowing access from all Azure services and globally from your client IP is convenient for development but should be restricted in production environments. Consider using private endpoints or more specific firewall rules for enhanced security.
Next Steps
Congratulations! You have successfully created and configured your first Azure SQL Database. You can now explore various options: